I am trying to make it so if you touch a block a block become cancollide, if you get off it uncancollides. I have NPCs too, and they trigger the code and I don't want them to trigger it. I've been trying to do this and I can't find anything on google or youtube that will help me. Please help.
Thank You!
(My Code)
local block1 = game.Workspace.FrontBlock1
local block2 = game.Workspace.FrontBlock2
local block3 = game.Workspace.BackBlock1
local block4 = game.Workspace.BackBlock2
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
wait(0.5)
block1.CanCollide = true
block2.CanCollide = true
block3.CanCollide = true
block4.CanCollide = true
else
block1.CanCollide = false
block2.CanCollide = false
block3.CanCollide = false
block4.CanCollide = false
end
end)

1 comment
I believe there is more complicated and useful methods, but I hope this helped! Thanks for reading!