I am making a script where when I touch a part it changes other part's properties, then it is meant to change my leaderstats Stage Value to 1 if it is on 0 else do nothing, after that is some more propertie changing.
game:WaitForChild("Players").PlayerAdded:Connect(function(plr) script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then if workspace:FindFirstChild("Walls", true) then local wall = workspace.Walls:FindFirstChild("Wall4", true) wall.CanCollide = true wall.BrickColor = BrickColor.new("Really red") script.Parent.CanCollide = false script.Parent.BrickColor = BrickColor.new("Really red") game.ReplicatedStorage.NightSky.Parent = game.Lighting if plr.leaderstats.Stage.Value >= 0 then plr.leaderstats.Stage.Value = 1 else end wait(15) if workspace:FindFirstChild("Walls", true) then local Wall1 = workspace.Walls:FindFirstChild("Wall5", true) Wall1.CanCollide = false Wall1.BrickColor = BrickColor.new("Lime green") game.Workspace.Enemies.Dark.Zombie.WalkSpeed = 0 end end end end) end)
Idk if this work but you can try
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if game.Workspace:FindFirstChild("Walls", true) then local wall = game.Workspace.Walls:FindFirstChild("Wall4", true) wall.CanCollide = true wall.BrickColor = BrickColor.new("Really red") script.Parent.CanCollide = false script.Parent.BrickColor = BrickColor.new("Really red") game.ReplicatedStorage.NightSky.Parent = game.Lighting if player:FindFirstChild("leaderstats").Stage.Value >= 0 then player:FindFirstChild("leaderstats").Stage.Value = 1 wait(15) if game.Workspace:FindFirstChild("Walls", true) then local Wall1 = game.Workspace.Walls:FindFirstChild("Wall5", true) Wall1.CanCollide = false Wall1.BrickColor = BrickColor.new("Lime green") game.Workspace.Enemies.Dark.Zombie.WalkSpeed = 0 end end end end end)