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

Speed script not working?

Asked by 9 years ago

~~~~~~~~~~~~~~~~~ --Trying to make the script to where when you step on (Block) it makes your speed 75

function speedBlock() print ("Character Speed Equals 75") Block.Touched.Humanoid.Walkspeed = 75

end Block.Touched:connect(speedBlock) ~~~~~~~

2 answers

Log in to vote
2
Answered by
tumadrina 179
9 years ago

well, the script doesn't know what Block is and also, you have to make the humanoid's walkspeed 75 not the thing touching it(example:right leg, left leg), one last thing, is you should probably make sure the thing touching it is part of a player

script.Parent.Touched:connect(function(hit)--put scripting under the part
    local Character=hit.Parent:GetChildren() 
    for i,v in pairs(Character) do
        if v.Name=="Humanoid" then--checks if it is a player
        hit.Parent.Humanoid.WalkSpeed=75
        end
    end
end)
Ad
Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

There are many problems with your script.

Firstly, you never defined 'Block', used in your connection statement. 'Block' is nil. Secondly, you don't index the part that touched with [Part].Touched. You have to set a parameter in your 'speedBlock' function, this parameter will help you access the part that touched due to the fact that Touched Events return the part that touched.

So, to fix your script?

local Block = game.Workspace.Part --Define 'Block' here

Block.Touched:connect(function(hit)
    print ("Character Speed Equals 75") 
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        hit.Parent.Humanoid.WalkSpeed = 75
    end
end)

You might also want to consider adding a Debounce

Answer this question