so i am trying to make a door and i have these invisible blocks infront of the door when you walk in the invisible blocks it is supposed to lerp open the doors
(i am not at the lerping yet and it isn't the problem )
i have placed 'Print('Hello!')' in several places of my script to see where it goes wrong because there is nothing in the output
THE SCRIPT:
colision = script.Parent game.Players.PlayerAdded:connect(function(player) print("Hello!1") player.CharacterAdded:connect(function(char) print("Hello!2") local torso = char['Torso'] colision.Touched:connect(function(hit) print("Hello!3") if hit.Parent == torso then print("Hello!4") end end) end) end)
in the output it prints the 'hello!1, hello!2 and hello!3 but not the fourth one'
i think i did something wrong at line 7 'local torso = char['Torso']' but i wouldn't know what i was away from scripting for a long time...
if there is anything missing just comment any help is appreciated
You're comparing the Parent of hit
to torso
, so if the Torso touches the part, it'll compare the character model (which is the Parent of the Torso) to torso
.
i.e.
if hit.Parent == torso then
turns into
if hit == torso then
Like BlupoV2 said you are comparing the player's character to torso which shouldn't return true
Usually people do something like look for a humanoid inside of the parent
colision = script.Parent game.Players.PlayerAdded:connect(function(player) print("Hello!1") player.CharacterAdded:connect(function(char) print("Hello!2") local torso = char['Torso'] colision.Touched:connect(function(hit) print("Hello!3") if hit.Parent:FindFirstChild("Humanoid") then print("Hello!4") end end) end) end)