I'm new to scripting and this script only works in Roblox studio why is that
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local head = char:WaitForChild('Head') while wait(4/10) do local speed = head.Velocity.Magnitude if speed >=4 then workspace.Events.addStep:FireServer() elseif speed <= 1 then end end end) end)
FireServer
from the server, when it should be called on the client. RemoteEvent.FireClient
may be what you're looking for. The purpose of remotes is to let the server and client communicate. How would it make sense, with remotes, for the server to communicate with itself? It doesn't. Changes made by the server replicate to all clients, so you won't need remotes for this.game.Players.PlayerAdded:Connect(function(plr) -- connect is deprecated plr.CharacterAdded:Connect(function(char) local head = char.Head while head.Velocity.Magnitude >= 4 do -- make it all one condition! workspace.Events.addStep:FireClient(plr) wait(4/10) end end) end)
local function addStep() -- do your code end game.Players.PlayerAdded:Connect(function(plr) -- connect is deprecated plr.CharacterAdded:Connect(function(char) local head = char.Head while head.Velocity.Magnitude >= 4 do -- make it all one condition! addStep() -- call function wait(4/10) end end) end)