My script don't work

This is the script idk why it’s don’t work

game.Players.PlayerAdded:Connect(function(player)
	script.Parent.Touched:Connect(function()
	game.StarterGui.SkyScript.Disabled = false
	game.StarterGui.SkyScript.Disabled = true
	player.leaderstatsP.Sky.Value = 1
	player.leaderstats.Stage.Value = 151
	player.Character.Humanoid.Health = 0
	end)
end)
1 Like

I’ve noticed you’re using StarterGui. Is this intentional, or are you wanting to change something for a specific player instead?

2 Likes

I want to change something for special player

the script change the sky in the Lighting not in ui

If that’s for a specific player, then use a localscript.

Sorry about that, I’m juggling a few things at once here.

bro i used a local script but i put an part in stage 149 that make the local script work and off again

You are creating a new connection for each player that joins. This means that when any player touches the part, the game won’t know which player touched it, so it will change for all the players. To fix this just use the touched event and get the player from the character that touched the part.

script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- get the player from the character that touched the part
	player.PlayerGui.SkyScript.Disabled = false
	player.PlayerGuiGui.SkyScript.Disabled = true
	player.leaderstatsP.Sky.Value = 1
	player.leaderstats.Stage.Value = 151
	player.Character.Humanoid.Health = 0
end)

That is the local script

local clone = game.ReplicatedStorage.Sky:Clone()
clone.Parent = game.Lighting

nice tysm that’s work but i made a few changes

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- get the player from the character that touched the part
	player.PlayerGui.SkyScript.Disabled = false
	wait(10)
	player.PlayerGui.SkyScript.Disabled = true
	player.leaderstatsP.Sky.Value = 1
	player.leaderstats.Stage.Value = 151
end)
1 Like

you changed the reply lol …