#it works when you turn on but it dosent turn off please help
23 messages · Page 1 of 1 (latest)
Brick color isnt a string
You gotta compare it with another brick color
i want the animation to stop though
the colors work
i just want the animation to stop
Here you’re checking if the background color is a string, which it will never be
Youve gotta check if its equal to BrickColor.new("Lime green")
@ashen temple
You have done on = true in the function but.. you never had it no = false afterwards.
I don't really know what you are making but, after turning it off, it the code proceeds and do stuff meant for turning it on, but by using else, you can have both actions separated.
local ui = script.Parent
local animation = script.Animation
local plr = game.Players.LocalPlayer
ui.Activated:Connect(function()
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
local anim = hum:LoadAnimation(animation)
if ui.BackgroundColor == BrickColor.new("Lime green") then
ui.BackgroundColor = BrickColor.new("Really red")
anim:Stop()
else
ui.BackgroundColor = BrickColor.new("Lime green")
anim:Play()
task.wait(1)
end
end)
Also, please send the code in text, not in screenshot.
Using ` symbol (back-tick).
alright it works kinda not fixed really but when i click it, it turns green and the animation plays and when i press it again it turns red but the animation dosent stop
I don't really know how to deal with animations, it could be that :LoadAnimation() "creates" a new one.
So :Stop() is stopping another "animation" instead of the one currently playing.
It is just my guess though, but I would sleep soon.