if game.Workspace.Brick then
Something like that but the if triggers if there is a Brick in game.Workspace
if game.Workspace.Brick then
Something like that but the if triggers if there is a Brick in game.Workspace
if game.Workspace:FindFirstChild("Brick") then
--do stuff--
end
if then and ends work like this
if true then
end
it has to be true to actually do it so it's an if statement if its false then it wont carry out
:findfirstchild("") if its found returns a true
Hey! I'm BlackOrange here to help!
First to check if something simply is there, we could use something as simple as a if statement to check either something is there or not then decide if we should execute the code.
-- ServerScript
if game.Workspace.Part then
end
-- OR
if game.Workspace:FindFirstChild('Part') then
end
Now if you mean detect by .Touched or walking through a door and trigger something then using .Touched may be the best option:
game.Workspace.Part.Touched:Connect(function()
-- trigger something
end)
Now .Touched will fire many times so we should add a debounce
local d = true
game.Workspace.Part.Touched:Connect(function()
if d then
d = true
-- trigger something
wait(1)
d = false
end)
Anyway this is probably how you "Detect" something. There are other ways such as :IsA() and many more ways to identify what is what.
Best of luck!
This discussion is preserved as it was. New answers, comments, and votes are closed.