#my "make player run" script doesnt work after respawning

1 messages · Page 1 of 1 (latest)

surreal flower
#

basically this code makes the player run when holding shift, but it doesnt work after respawning, can someone help me with this

safe bear
#

Is this a starter character or starter player script

surreal flower
#

starter player script

safe bear
#

Hmm

#

I gues you could try a starter character script?

surreal flower
#

ill try that

viral oracleBOT
#

studio** You are now Level 1! **studio

surreal flower
#

it does

#

thanks man

safe bear
#

Alright

near prawn
meager vortex
#

a workaround to this would be to change the assign the character variable the player's new character each time upon respawning

#
local player = game:GetService("Players").LocalPlayer
local character = player.LocalPlayer or player.CharacterAdded:Wait()
local function doStuff()
  character.Humanoid.WalkSpeed = math.random(1,500)
end
while true do
  doStuff()
  task.wait()
end
player.CharacterAdded:Connect(function(newCharacter)
  character = newCharacter
end)
#

something like this could work, but i think it could lead to some errors

#

it would fix your problem though

#

but edge cases like a player trying to sprint when their character doesn't have a humanoid might make the script error

#

just use protected function calls to mitigate that