i forget if its called statements or not sorry if the titles wrong haha
I’m making a silly cart ride game and I’ve been stuck on a part of a script with a local
statement (line marked with comment). If I just keep one string then both respective seats work, but together they don’t. With the way it is currently, it only works if I get into the seat named Seat
and kills me (which is supposed to happen) but if I get into the seat named Safe
, it doesn’t and instead prints "no person in seat"
. The cart has to have 1-2 players in it.
I’ve also tried local seat = hit.Parent:WaitForChild("Safe") or hit.Parent:WaitForChild("Seat") or (hit.Parent:WaitForChild("Safe") and hit.Parent:WaitForChild("Seat"))
but that didn’t work as well.
local debouce = false
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Cart" then
if not debouce then
debouce = true
local seat = hit.Parent:WaitForChild("Safe") and hit.Parent:WaitForChild("Seat") --only checks "Seat" and not "Safe"
if seat.Occupant then
local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
seat:SetAttribute("Player", player.UserId)
if seat.Occupant.Parent:WaitForChild("DidYouFindTheChildOrNot").Value == false then
seat.Occupant.Health = 0
else
seat.Occupant.Jump = true
end
else
if not seat.Occupant then
print("no person in seat") --prints when im sitting in "Safe" seat ??
end
end
task.wait(8)
debouce = false
end
end
end)