Hey there Scripting Helpers! So to get to the point, whenever I try playing the animations from the GUI, they fire and play correctly, but when I press them again to stop it, it'll just restart the animation from the beginning, instead of stopping it. As you can see I did add 'Prints' to the portion of the code that handles firing and stopping the animation, and they are showing up in output. Here's the code from the Local Script i'm using:
local uis = game:GetService("UserInputService")
local event = game.ReplicatedStorage.Play
local event2 = game.ReplicatedStorage.Stop
local moving = false
local playing = false
local sameTile = true
local select = 1
local holder = script.Parent:WaitForChild("Holder")
local up = script.Parent:WaitForChild("Up")
local down = script.Parent:WaitForChild("Down")
local click = script.Parent:WaitForChild("SelectFrame")
holder:WaitForChild("D1")
holder:WaitForChild("D2")
holder:WaitForChild("D3")
holder:WaitForChild("D4")
local list = {
}
local animations = {
{"Breakdance", 1410598537},
{"Breakdance 2", 1410601789},
{"Breakdance 3", 1410604682},
{"Orange Justice", 2034118828},
{"Chicken Dance", 1410603640},
{"Gucci Stride", 1410599787},
{"Floss", 2047021788},
{"Salsa", 1410607124},
{"Fast Hops", 1410610859},
{"Frog Dance", 1410612088},
{"Crazy Dance", 1410626217},
{"Gangnam Style", 1410613206},
{"HipHop 1", 1410617910},
{"HipHop 2", 1410619130},
{"Brooklyn Bop", 1410628065},
{"Robot", 1433068288},
{"Running Man", 1433070909},
{"Flare", 1433072776},
{"Mixer", 1433074490},
{"Pump It", 1433076248},
{"Hype", 2047023967},
{"Yeet", 2047014506},
{"Freestyle 1", 2047012717},
{"Freestyle 2", 2047016301},
{"Cat Call", 2395484047},
{"Belly Dance", 4553967681},
{"Jockey", 4553983785},
{"Party Bop", 4553975384},
{"The Twist", 4553987799},
}
local order = {
holder.D1,
holder.D2,
holder.D3,
holder.D4,
}
for i = 1, 3 do
order[i].Label.Text = animations[i][1]
end
local function sup()
if moving == false then
moving = true
sameTile = false
select = select - 1
if select < 1 then
select = #animations
end
local extra = order[4]
table.remove(order, 4)
table.insert(order, 1, extra)
extra.Position = UDim2.new(0, 0, 0, -82)
extra.Label.Text = animations[select][1]
for i, box in ipairs(order) do
box:TweenPosition(UDim2.new(0, 0, 0, box.Position.Y.Offset + 82), "Out", "Quad", 0.1, true)
end
wait(0.12)
moving = false
end
end
local function sdown()
if moving == false then
moving = true
sameTile = false
select = select + 1
if select > #animations then
select = 1
end
for i, box in ipairs(order) do
box:TweenPosition(UDim2.new(0, 0, 0, box.Position.Y.Offset - 82), "Out", "Quad", 0.1, true)
end
wait(0.12)
local extra = order[1]
table.remove(order, 1)
table.insert(order, 4, extra)
extra.Position = UDim2.new(0, 0, 0, 246)
local set = 0
if (select + 3) > #animations then
set = select + 3 - #animations
else
set = select + 3
end
extra.Label.Text = animations[set][1]
moving = false
end
end
local function play()
if moving == false then
if playing == false then
event:FireServer(animations[select][2], true)
playing = true
sameTile = true
elseif (sameTile == true) and (playing == true) then
event2:FireServer(animations[select][2], false)
playing = false
print("Event2Pass")
elseif (sameTile == false) and (playing == true) then
event2:FireServer(animations[select][2], false)
playing = false
sameTile = false
print("Event2Pass2")
end
end
end
uis.InputBegan:connect(function(input, bool)
if bool == false then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Q then
sdown()
elseif input.KeyCode == Enum.KeyCode.E then
sup()
elseif input.KeyCode == Enum.KeyCode.R then
play()
end
end
end
end)
click.MouseButton1Down:connect(play)
down.MouseButton1Down:connect(sdown)
up.MouseButton1Down:connect(sup)
