Hello,
I have a mobile sprint button that breaks when the player dies. The UI is still there once the player respawns, but clicking the button won’t do anything. Furthermore, the code is still under the UI when the player resets, yet clicking the button won’t work still.
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
script.Parent.MouseButton1Click:Connect(function()
local WalkSpeed = 16
local SprintSpeed = 24
if script.Parent.ImageColor3 == Color3.new(0.392157, 0.392157, 0.392157) then
script.Parent.ImageColor3 = Color3.new(0.580392, 0.580392, 0.580392)
Humanoid.WalkSpeed = SprintSpeed
else
script.Parent.ImageColor3 = Color3.new(0.392157, 0.392157, 0.392157)
Humanoid.WalkSpeed = WalkSpeed
end
end)