#my "make player run" script doesnt work after respawning
1 messages · Page 1 of 1 (latest)
Is this a starter character or starter player script
starter player script
ill try that
** You are now Level 1! **
Alright
if you get any issues, consider just using this: https://www.roblox.com/library/12840827723/SHIFT-TO-SPRINT-WITH-STAMINA-BAR
Roblox is a global platform that brings people together through play.
issue with this is that you're referencing the player's character only one time, and that one reference is obtained the very first time the player spawns. when they die and respawn, a new character is created, and the old one is destroyed/removed. your code would effectively be changing the walkspeed of the very first character, not the current one.
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