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

How can i execute this script if a humanoid touchs a block?

Asked by 6 years ago

I want this script to happen when the humanoid touches a block, simple request.

1-- script
2    game.Workspace.OHHH.Position = Vector3.new(77.6, 2.5, -195.4)
3 
4    wait(3)
5 
6    game.Workspace.OHHH.Position = Vector3.new(76.6, 2.5, -193)
7wait(3)
0
humanoid can't touch plocks HappyTimIsHim 652 — 6y

2 answers

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago
1local Part = workspace:FindFirstChild("touchobjectname")
2Part.Touched:Connect(function(PartThatTouchedThePart)
3   --//Whatever happens when the part was touched
4end)
0
thx! Adenandpuppy 87 — 6y
0
Anytime! Ziffixture 6913 — 6y
Ad
Log in to vote
1
Answered by
Z9R 5
6 years ago

so what you want to do is use the "Touched" event. So what you want to do is insert a script inside the block and add this code to it.

1script.Parent.Touched:connect(function(part) -- part is the part that touched it.
2    if game.Players:FindFirstChild(part.Parent.Name) then-- sees if the part that touches it is a player
3    local plr = part.Parent
4     --Code goes here.
5    end
6end)

if you need more help feel free to check out this wiki page - https://developer.roblox.com/api-reference/event/BasePart/Touched

Answer this question