Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to give walkspeed when equpping tool?

Asked by
sheepposu 350 Moderation Voter
6 months ago

So I have a script on a speed coil but I can't figure out how to give the person speed when they equip it.

local speed = script.Parent.Speed.Value
local Tool = script.Parent

Tool.Equipped:Connect(function()
    game.Humanoid.WalkSpeed = speed
end)

Tool.Unequipped:Connect(function()
    game.Humanoid.Walkspeed = 16
end)

1 answer

Log in to vote
0
Answered by 6 months ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

local script inside tool

local Speed = script.Parent.Speed
local Tool = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

Tool.Equipped:Connect(function()
    Humanoid.WalkSpeed = Speed.Value
end)

Tool.Unequipped:Connect(function()
    Humanoid.WalkSpeed = 16
end)
Ad

Answer this question