Hello, I am trying to make a queue line ystem where you walk in a queue, your speed changes to slower, you reach the end and walk out and your speed goes back to 16. It does not seem that hard but is just getting more difficult as I go on.
I am using a UI so when your in the queue a UI will pop up and give you the option to leave the queue. It all works but as the UI script will be in a local script I am using a remote event to know when the “leave queue” button has been clicked in my main server script. I am doing this so when the leave queue button has been pressed I can then reset the players walkspeed and allow them to rejoin the queue.
This is not the case, everything is working (It is changing the players speed and teleporting them outside of the queue) but it is not setting the queueLineStatus back to false, meaning when the player joins the queue again it does not change its speed as it thinks the queueLineStatus for the player is still true. (Sorry if that didn’t make sense please tell me if it didn’t). It only resets the queueLineStatus to false when the player walks to the end of the queue.
Here is my server script code:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local queueLineStatusEvent = ReplicatedStorage.leaveQueueStatus local Players = game:GetService("Players") local StarterGUI = game:GetService("StarterGui") local queueUI = StarterGUI.queueUI local queueLineStart = script.Parent.queueLineStart local queueLineEnd = script.Parent.queueLineEnd local queueLineStatus = false; local queueLineSpeed = 6 local walkSpeed = 16 local function onQueueLine(player, queueLineStatus) local startOfQueueTeleportPos = CFrame.new(-7, 0.5, 64) queueLineStatus = false player.Character:WaitForChild("Humanoid").WalkSpeed = walkSpeed player.Character.HumanoidRootPart.CFrame = startOfQueueTeleportPos print(player.Name .." fired the queueLineStatus remote event!") end queueLineStatusEvent.OnServerEvent:Connect(onQueueLine) queueLineStart.Touched:Connect(function(hit) local plr = Players:GetPlayerFromCharacter(hit.Parent); if (plr and not queueLineStatus) then queueLineStatus = true plr.Character:WaitForChild("Humanoid").WalkSpeed = queueLineSpeed plr.PlayerGui.queueUI.Enabled = true print("Player has entered the queue line and their speed has been changed to "..queueLineSpeed) end end) queueLineEnd.Touched:Connect(function(hit) local plr = Players:GetPlayerFromCharacter(hit.Parent); if (plr and queueLineStatus) then queueLineStatus = false plr.Character:WaitForChild("Humanoid").WalkSpeed = walkSpeed plr.PlayerGui.queueUI.Enabled = false print("Player has left the queue and their speed has been changed to "..walkSpeed) end end)
This may be a basic fix and easy to do but I am new in this and just need a bit of help. Also sorry if this does not make sense I am not the best at explaining.