I'm making a maze horror game, and you need to collect 5 objects to win the game, but my script has an error that i just can't see.
local orbs = game.Workspace.Orbs
local OrbsCollected = game.ReplicatedStorage.OrbsCollected
orbs.RedOrb.o4.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
OrbsCollected.Value = OrbsCollected.Value + 1
orbs.RedOrb:Destroy()
end
end)
orbs.YellowOrb.o5.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
OrbsCollected.Value = OrbsCollected.Value + 1
orbs.YellowOrb:Destroy()
end
end)
orbs.GreenOrb.o1.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
OrbsCollected.Value = OrbsCollected.Value + 1
orbs.GreenOrb:Destroy()
end
end)
orbs.PurpleOrb.o2.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
OrbsCollected.Value = OrbsCollected.Value + 1
orbs.PurpleOrb:Destroy()
end
end)
orbs.BlueOrb.o3.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
OrbsCollected.Value = OrbsCollected.Value + 1
orbs.BlueOrb:Destroy()
end
end)
if OrbsCollected.Value == 5 then
game.Workspace.WinDoor:Destroy()
end
When you reach 5 on the int value, the door still doesn't open for some reason. I don't really see the error here. Help would be appreciated.

3 comments
Thank you, it works, I will make sure to check if 5 is in a loop or a function.
If this works make sure to mark it as your answer so other developers / scripters know this is solved and your welcome.
OMG THANK YOU SO MUCH I LOOKED FOR THIS FOR 3 FRICKIN HOURS