Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

You forgot the 'end''s for the code. :/

0

Edited the script, this should work now.

1 answer

✓ Accepted answer
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.

5 comments

0

For some reason it did not work but thankyou any way

0

Press 'Accept Answer' when it works.

0

I fixed it BTW

0

Thankyou you are the best

0

upvote & accept answer pls

This discussion is preserved as it was. New answers, comments, and votes are closed.