Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this script that is supposed to change player speed not working?

The script is in a tool, and it is supposed to increase the player's speed when they equip it, and return their speed back to normal when they unequip it.

However, the script isn't working at all, and I don't know why. I did get output, however.

Can someone please help me?

Here's the script:

script.Parent.Equipped:connect(function()
script.Parent.Handle.CoilSound:Play()
if script.Parent.Parent:FindFirstChild("Humanoid") then
	script.Parent.Parent.Humanoid.WalkSpeed = 32
end
end)

script.Parent.Unequipped:connect(function()
script.Parent.Handle.CoilSound:Play()
if script.Parent.Parent:FindFirstChild("Humanoid") then
	script.Parent.Parent.Humanoid.WalkSpeed = 16
end
end)

Output: "Equipped is not a valid member of Model"

2 comments

0

The output tells me that script.Parent = a mode, post the ancestry tree so we can answer better.

0

This script seems to work fine for me. Are you sure you have a Handle inside the Tool? Since without the handle inside the tool the tool want work

1 answer

✓ Accepted answer

One thing to note, from what I have tested it will not work if there is no part in the Tool named Handle.

Here is the code for a LocalScript you can use, not sure why you're script won't work though.

Sorry I couldn't explain it any better.

wait(0.5) -- Prevent error's while searching for the player

local player = game.Players.LocalPlayer -- Easier way then repeating it alot of times

script.Parent.Equipped:connect(function() -- Equipped function
	script.Parent.Handle.CoilSound:Play() -- Play the sound
	if player.Character:FindFirstChild("Humanoid") then -- Search for the Humanoid
		player.Character.Humanoid.WalkSpeed = 32 -- Change the walkspeed
	end -- End the search
end) -- End the function

-- Won't explain below cause it is pretty much the same.

script.Parent.Unequipped:connect(function()
	--script.Parent.Handle.CoilSound:Play()
	if player.Character:FindFirstChild("Humanoid") then
		player.Character.Humanoid.WalkSpeed = 16
	end
end)

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.