Why is FireServer() from local script to server script firing for all player not one?

I am making an inventory system that equips things like particle effects ETC and it works great but one issue is that when the player clicks equip it works but it equipt the particle effect to all players, not just the one that clicked equip Here is my code:

Local Script

local function equipRick()
	if RickValue.Value == true then
		if purchaseImg.Image == "rbxassetid://13013809023" then
			equipEvent:FireServer("Rick", plr.UserId)
		end
	end
end

local function equipDog()
	if dogValue.Value == true then
		if purchaseImg.Image == "rbxassetid://13014229857" then
			equipEvent:FireServer("Dog", plr.UserId)
		end
	end
end

local function equipBag()
	if moneyBagValue.Value == true then
		if purchaseImg.Image == "rbxassetid://13014013620" then
			equipEvent:FireServer("Bag", plr.UserId)
		end
	end
end

Server Script:

local function changeP(plr, value)
	if value == "Rick" then
		emitter.Texture = "rbxassetid://13013809023"
		emitter.Enabled = true
	end
	if value == "Dog" then
		emitter.Texture = "rbxassetid://13014229857"
		emitter.Enabled = true
	end
	if value == "Bag" then
		emitter.Texture = "rbxassetid://13014013620"
		emitter.Enabled = true
	end
end

event.OnServerEvent:Connect(changeP)

Thanks.

You are setting emitter enabled, there is nothing using plr in your server script. I think we would need more context to tell how you want to make this script player-based

When someone equips an effect I want it to show for everybody on the server, not just the local player but I don’t know how to achieve that so I thought I could use a server script.

the event is in ReplicatedStorage right?
also you don’t need to pass the player’s userid since player is always given

equipEvent:FireServer(“Bag”, plr.UserId)

unless plr is someone else i guess

1 Like

Well, when you fire a remote event, you send 1 extra argument, which is the sender. So, look below.

Local Script:

game.ReplicatedStorage.MyEvent:FireServer("Dog", plr.UserId)

here you are sending the dog and then the player id

when you recieve it, there is an extra value.

serverscript

game.ReplicatedStorage.MyEvent.OnServerEvent:Connect(function(sender, plr, value)

end)

you get a sender value before the other values, it doesn’t matter how many arguments you send, there is always the sender value first, if you send 1 value, you recieve sender first and than that 1 value. The sender value is always first, then next is what ever values you sent.

1 Like