local speedBoost = script.Parent
local function steppedOn(part)
local parent = speedBoost.Parent
if game.Players:GetPlayerFromCharacter(parent)then
parent.humanoid.walkspeed = 50
end
end
speedBoost.Touched:Connect(steppedOn())
COMMUNITY QUESTION
i have this line of code and its supposed to make me faster why?
2 answers
You can't run functions in a connection, all you have to do is remove the () from the steppedOn function on line 10.
local speedBoost = script.Parent
local function steppedOn(part)
local parent = speedBoost.Parent
if game.Players:GetPlayerFromCharacter(parent)then
parent.humanoid.walkspeed = 50
end
end
speedBoost.Touched:Connect(steppedOn)
In Lua things are case-sensitive, meaning you should use Humanoid and WalkSpeed, not humanoid and walkspeed. Also, when connecting a function to a RBXScriptSignal, you must only put the function's name, not following by the ().
local speedBoost = script.Parent
local function steppedOn(part)
local parent = speedBoost.Parent
if game:GetService("Players"):GetPlayerFromCharacter(parent) then
parent.Humanoid.WalkSpeed = 50
end
end
speedBoost.Touched:Connect(steppedOn)
This discussion is preserved as it was. New answers, comments, and votes are closed.
