I’m trying to check if a part is equal to nil
, but it doesn’t seem to work. My end goal here is to check if a part has been touched, then when it is touched it destroys itself. Then the main script will repeat wait() until part == nil
, then it will perform some action.
This is the main script:
local showDialogue = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("ShowDialogue")
local setObjective = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("SetObjective")
local exitHospitalTrigger = game.Workspace:WaitForChild("Map"):WaitForChild("Triggers"):WaitForChild("DialogueTriggers"):WaitForChild("ExitHospitalTrigger")
local function startGame()
showDialogue:FireAllClients("")
setObjective:FireAllClients("")
showDialogue:FireAllClients("Huh? Where am I?")
wait(4)
showDialogue:FireAllClients("It kinda looks like an abandoned hospital...")
wait(4)
showDialogue:FireAllClients("Anyways, I need to get out of this place.")
wait(4)
setObjective:FireAllClients("Get out of the abandoned hospital.")
repeat wait() until exitHospitalTrigger == nil
showDialogue:FireAllClients("")
setObjective:FireAllClients("")
showDialogue:FireAllClients("I finally got out of that mysterious hospital...")
wait(4)
showDialogue:FireAllClients("But, I think I'm lost.")
wait(4)
showDialogue:FireAllClients("Oh, I'm screwed...")
wait(4)
setObjective:FireAllClients("Find your way back home.")
end
wait(5)
startGame()
And the part’s script:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
script.Parent:Destroy()
end
end)
This is the explorer if you need it:
And some gameplay:
As you can see, for some reason, it gets stuck on “Get out of the abandoned hospital” and it doesn’t progress to the next objective even though the part has been destroyed.
Help would be appreciated.