Server Client problem

example: i am the player 1
image

this is the shop – i wanna achieve like when i press equip i want to morph that burger
image

like this and also when i die i will respawn with that burger
image

the problem is when i equip this happen
image

i made a BoolValue that when the boolvalue is true u will morph that burger
here is the script

game.Players.PlayerAdded:Connect(function(plr)

	local SkinValue = Instance.new("Folder")
	SkinValue.Parent = plr
	SkinValue.Name = "SkinValue"

	burger = Instance.new("BoolValue")
	burger.Parent = SkinValue
	burger.Name = "Burger"
plr.CharacterAppearanceLoaded:Connect(function(chars)
		print(plr)
		print("character respawn")
----------------------------------------- Burger		
		if burger.Value == true then
			
		local char = plr.Character
		local face = char.Head.face
		face:Destroy()
			for i, v in pairs(char:GetDescendants()) do
				if v:IsA("Part") then
				
				v.Transparency = 1
				
					spawn(function()
						for i, v in pairs(char.Parent:GetChildren()) do
							if v:IsA("Accessory") == true or v:IsA("CharacterMesh") == true or v:IsA("Shirt") == true or v:IsA("Pants") == true or v:IsA("BodyColors") == true or v:IsA("ShirtGraphic") == true then
								v:Destroy()
							end
						end
					end)
					wait()
					
						local burger = game.ReplicatedStorage.Skin.Burger
						

						if not char:FindFirstChild("Burger") then
						local clone = burger:Clone()
						clone.Parent = char
						clone.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0,-1,0)
						
						local weld = Instance.new("WeldConstraint")
						weld.Parent = clone
						weld.Part0 = clone
						weld.Part1 = char.HumanoidRootPart
					end	
				end
			end		
		end -----

this is the triggered event when i press the equip

burgerevent.OnServerEvent:Connect(function(plr)
	burger.Value = true
end)

also i want to achieve cuz my really problem is im trying to make a boolvalue that when the value is true u will use the morph so i cant put the value on replicated or serverstorage cuz if i triggered one event player will gonna be morphed so thats why i put it on player

This script needs a lot of help first to diagnose the problem. I’m seeing issues where you’re spawning a function to find accessories, as well as cloning the burger from storage, for every child within the character. All that shouldn’t be nested within a for-loop (the char:GetDescendants() one) since it should happen only once. You also reference char.Parent:GetChildren() on the players’ character, which will return a table outside of the scope of the player. Workspace I believe.

The issue you’re describing looks to be because you’re using a variable “burger” globally in the script, updated by the RemoteEvent, but then reassign “burger” to be a BoolValue, and again to reference it in cloning the burger. These all need to be separate values. Player 2 seems to be receiving the burger because “burger” is updated outside of the PlayerAdded event to be true when any player equips burger, so anyone new that joins will be compared to that value. All players shouldn’t share a boolean for this either, perhaps create a BoolValue parented to each player, and compare if ply.Burger.Value then... instead.

1 Like

is this what u mean im going to change this

if burger.Value == true then

into this

if plr.SkinValue.Burger.Value == true then

That would work! Then make sure the SkinValue folder and the Burger BoolValue exist prior, like by creating it when the player first joins.

1 Like

Thank u so much u help my game :))