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

Is it possible to change the speed of any player that touches a specific brick?

Asked by 11 years ago

local part = Instance.new('Part', Workspace) part.Anchored = true part.Transparency = .5 part.BrickColor = BrickColor.new('Bright red') part.Touched:connect(function() game.Workspace.Player1.Humanoid.WalkSpeed = 200 end)

What i specifically mean is that when anyone touches that bright red brick that is created into the workspace, how do I make it that when 'anyone' touches it, their speed turns to 200?

game.Workspace.Player1.Humanoid.WalkSpeed=200

I am sure that is the line I have to change, but I am not sure what to change it too to make sure that when 'anyone' touches it, there speed is made 200.

2 answers

Log in to vote
0
Answered by
u_g 90
11 years ago

Insert this script into your brick.

1function onTouched(hit)
2local h = hit.Parent:findFirstChild("Humanoid")
3if h == nil then return end
4if h ~= nil then
5h.WalkSpeed = 200
6end
7end
0
Whups. Forgot. Insert "script.Parent.Touched:connect(onTouched) after the second "end". u_g 90 — 11y
0
The "if h == nil then return end" Is unecessary and literally does nothing... jav2612 180 — 11y
0
That's to check if the humanoid is there. If it's not, then return end... u_g 90 — 11y
0
"if h ~= nil then" checks if the humanoid is there. there is no purpose for the if before that, it will function the same without it. jav2612 180 — 11y
Ad
Log in to vote
0
Answered by
jav2612 180
11 years ago
01local part = Instance.new("Part", Workspace)
02part.Anchored = true
03part.Transparency = 0.5
04part.BrickColor = BrickColor.new("Bright red")
05 
06function touched(p) -- p is the part that touched the Part
07    if p.Parent:FindFirstChild("Humanoid") ~= nil then -- check to make sure its a character
08        p.Parent.Humanoid.Walkspeed = 200
09    end
10end
11part.Touched:connect(touched)
0
thank you. smokeybeetle 0 — 11y

Answer this question