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 5 years ago

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

-- script
    game.Workspace.OHHH.Position = Vector3.new(77.6, 2.5, -195.4)

    wait(3)

    game.Workspace.OHHH.Position = Vector3.new(76.6, 2.5, -193)
wait(3)
0
humanoid can't touch plocks HappyTimIsHim 652 — 5y

2 answers

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

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

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