Tool Script Help

I’m trying to make a script so that when you equip it gives you extra speed, sorta like a speed coil, I can’t get it to work. Here is what I made:

local speed = 00 --How fast you want to go.

game.Players.PlayerAdded:Connect(function(p)

local Tool = player.StarterGear:FindFirstChild("ToolName") 

Tool.Equipped:Connect(function()

p:WaitForChild("Character").Humanoid.WalkSpeed = speed


end)

Tool.Unequipped:Connect(function()
p:WaitForChild("Character").Humanoid.WalkSpeed = 16

end)
end)

If you see anything wrong, please let me know.

I have found a couple of things. First of all, is this a local or server script?

Should be player.Backpack.ToolName

Also from the way this is scripted I think the script would stop working when they die

First off, is that a LocalScript or a Server Script?
If that’s a Server Script then insert a LocalScript inside your tool and paste this in:

local p = game:GetService("Players").LocalPlayer
local char = p.Character or p.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local defaultSpeed = humanoid.WalkSpeed
local customSpeed = 00 --How fast you want to go.

local Tool = script.Parent

Tool.Equipped:Connect(function()
hum.WalkSpeed = customSpeed
end)

Tool.Unequipped:Connect(function()
hum.WalkSpeed = defaultSpeed
end)

If that’s a LocalScript and it is inside your tool then you can copy and paste the code above into your script.

2 Likes

It’s a script in serverscriptservice.

did you try my thing

switch startergear to backpac

also does the tool have a handle and if not is the requirehandle property off

Not sure, do I check that in properties?

go to the tool is there a handle under it?

yes click the tool then look in properties

did you change startergear to backpack

I changed it to script.Parent like @Giggio450BR did, but thanks for the help.