Still have questions? Join our Discord server and get real time help.
0

# How do i code Wait Until LocalPlayer Touches Brick?

I want to know how to do that.

0

you need an localscript inside the part you want to detect if touched and when you have it

you just need this code:

function Touched(part1) -- inside the brackets put the name of ur part
local h = part1.Parent:findFirstChild("Humanoid")
if h~=nil then
-- this is where your action goes
end

end

script.Parent.Touched:connect(Touched)

0

First we need the part, so you can create and edit it to be however you want

Next we need to start coding :)

Insert a local script and use this code:

script.Parent.Touched:Connect(function(hit) --Detect when the part is touched
--Detect if humanoid exists
if hit.Parent:FindFirstChild("Humanoid") then
--This code executes when the player touches the part
print("Player touched part")
end
end)


.Touched only runs when the part is touched by anything. Another part, or the player.

A local script only runs on the client so the server or other players cannot see it. If you want other players or the server to see it, you need to use remote events.

0

These 2 answers didn't help me it just executes a code when localplayer touches a block instead of wait until localplayer touches a block, I had to do a workaround myself and it took me 10 hours to do so... :(

local untiltouchblock = 0
function Touched(part1)
local h = part1.Parent:findFirstChild("Humanoid")
if h~=nil and untiltouchblock == 0 then
untiltouchblock = 1
end
script.Parent.Touched:connect(Touched)
repeat wait() until untiltouchblock == 1