Why it gives someone the perks too?

When i equip the perks it equip to all can someone help me to only give it to person who equip.

local Player = game.Players.LocalPlayer
local player = game.Players.PlayerAdded:Connect(function(player)
	local Character = player.CharacterAdded:Connect(function(Character)
	
		game.ReplicatedStorage.TrailScripts.Equip.Golden.OnServerEvent:Connect(function(Player)
			
			--[[local MutatorsFolder = Player:WaitForChild("HeadStats")


			for i, v in pairs(MutatorsFolder:GetChildren()) do

				v.Value = 0
			end--]]
	
			
			local Golden = game.ReplicatedStorage.Trails.Golden:Clone()
			local Parents = Golden.Attachment
			Parents.Parent = Character.Torso
			
			Player:WaitForChild("BodyStats").Golden.Value = 0
			
				
			end)
			
	end)
end)

To be clear, do you want this to run when a player joins the game, or when the RemoteEvent is fired?

I’ve already spotted a lot of issues with you code, which I will outline once I understand how you want the code to work. It looks like you’re using PlayerAdded but you’re also using a RemoteEvent (hence OnServerEvent) so I’m wondering whether you want the code to run when a player joins or when the Remote is fired.

No this is how it works :

I equip it on starter gui and i fire it so i will get the perks on my body.

why do you have the onserverevent under playeradded and characteradded events? Of course its gonna give to everyone because when you fire to the server, everyone a part of the characteradded event gets the server event the player parameter no longer means anything because its overridden by the character variable (which everyone currently on server will have and since its fired under everyone, everyone will get it)

Just separate the onserver event from the local character and player–i don’t understand why its under it in the first place…

1 Like

However i fix my own problem but theres 1 more new bug

local Player = game.Players.LocalPlayer

	

game.ReplicatedStorage.TrailScripts.Equip.RemoteAlpha.OnServerEvent:Connect(function(player, Player)
	
	
		
			local Character = player.Character or player.CharacterAdded:Wait()
		
			local MutatorsFolder = player:WaitForChild("HeadStats")

			for i, v in pairs(MutatorsFolder:GetChildren()) do

				v.Value = 0
			end
	
			Player:WaitForChild("HeadStats").Alpha.Value = 0
	
			if Character.Head:FindFirstChild("Godly") then
				Character.Head:FindFirstChild("Godly"):Destroy()
				else
			end
			local Gui = game.ReplicatedStorage.Trails.Alpha:Clone()

	Gui.Parent = Character.Head
	
		
	
end)

ServerScriptService.TrailHandler.Equips - Alpha.Equip - Trail:18: attempt to index nil with 'WaitForChild’

thats in a seperate script you havent shown.

I just update those script that i mention.

ServerScriptService.TrailHandler.Equips - Alpha.Equip - Trail:18: attempt to index nil with 'WaitForChild’

is not the same script or you havent shown the code

You have two player variables, one with a capital letter. First off, don’t do that because you can get confused and then this exact scenario happens. Second, delete all references to the capital Player and just use the lowercase one.

1 Like

What do you mean ? @JarodOfOrbiter

you have 2 player parameters in your on server event for literally no reason

I also don’t know why you are fetching the local player out in the open on a server script either

The player parameters is for character added so i wont use player added also the Player parameter is for local player so i can change the value on it.

To answer your question about the local player on server script it also works when you have function on it.

Can somebody help me with this bug?

ServerScriptService.TrailHandler.Equips - Alpha.Equip - Trail:18: attempt to index nil with 'WaitForChild’

you’re indexing nil in trailhandler. You still haven’t shown code about it either

The script is above that error :

local players = game.Players.LocalPlayer

	

game.ReplicatedStorage.TrailScripts.Equip.RemoteAlpha.OnServerEvent:Connect(function(player,players)
	
	
		
			local Character = player.Character or player.CharacterAdded:Wait()
		
			local MutatorsFolder = player:WaitForChild("HeadStats")

			for i, v in pairs(MutatorsFolder:GetChildren()) do

				v.Value = 0
			end
	
			players:WaitForChild("HeadStats").Alpha.Value = 0
	
			if Character.Head:FindFirstChild("Godly") then
				Character.Head:FindFirstChild("Godly"):Destroy()
				else
			end
			local Gui = game.ReplicatedStorage.Trails.Alpha:Clone()

	Gui.Parent = Character.Head
	
		
	
end)

whats the name of the script? because i do not see “Alpha.Equip” anywhere in it

You still shouldn’t have your variables named so similarly.

This doesn’t work at all in a server script, you can delete this. It does literally nothing and deleting it won’t affect your code in any way.

If this is line 18 (you forgot to specify which line was which) then it means players is nil. Your issue then is with the script calling the remote event.