Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to give walkspeed when equpping tool?

Asked by
sheepposu 561 Moderation Voter
5 years 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
LuaDLL 253 Moderation Voter
5 years 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