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

Theres a error in the script I'm making but I don't know where it is?

Asked by
duckyo01 120
9 years ago

Im trying to make a brick that lets you walk on it with a certain walkspeed but I thought I did everything right but it does not work. Here it is:

Player = game.Player.LocalPlayer
function onTouch(part)
if Player.Walkspeed = 40 then
part.CanCollide = true
else
part.CanCollide = false
script.Parent.Touched:connect(onTouch)

I still don't see where I'm wrong?

0
You forgot the 'end''s for the code. :/ TheeDeathCaster 2368 — 9y
0
Edited the script, this should work now. killerkill29 35 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago
script.Parent.Touched:connect(function(hit)
    if game.workspace:FindFirstChild(hit.Parent.Name):WaitForChild('Humanoid').WalkSpeed == 40 then
        script.Parent.CanCollide = true
    else
        script.Parent.CanCollide = false
    end
end)


Alright. in the function hit, that is the person who touches that brick. To find him/her in workspace, we use hit.Parent.Name. Then, we look for humanoid, and then check for walkspeed. If the walkspeed is 40, it will be solid. If not, it will not be solid. Keep in mind, if 2 people touch it at the same time, (one person with 16 walkspeed and one with 40 walkspeed), the brick will be glitchy, and will flash.

0
For some reason it did not work but thankyou any way duckyo01 120 — 9y
0
Press 'Accept Answer' when it works. killerkill29 35 — 9y
0
I fixed it BTW killerkill29 35 — 9y
0
Thankyou you are the best duckyo01 120 — 9y
0
upvote & accept answer pls killerkill29 35 — 9y
Ad

Answer this question