Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Remote Event,player argument must be a Player object , How would I find the player object?

local UnequipEvent = game.ReplicatedStorage.Folder.Unequipped
local Tool = script.Parent.Parent
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer


Tool.Unequipped:Connect(function()
	
		UnequipEvent:FireClient(game.Players.LocalPlayer)
		print("yes")
	end)

I do not understand what is the player object is supposed to be, I tried multiple things, But none of them worked, Anyone can help me out?

1 comment

0

UnequipEvent:FireClient(player)

2 answers

✓ Accepted answer

In the developer wiki, it uses Player.PlayerAdded. I don't know if it would work in your situation, but you could also say something like this:

local players = game.Players
for i, v in ipairs(players) do
UnequipEvent:FireClient(v) --I didn't indent it because then you would have to replace the spaces with tabs.
end

If you don't think these would work in your circumstance, try using a localscript.

I hope this helps!

3 comments

0

In that case, woudn't it be better if you use UnequipEvent:FireAllClients() ?

0

RocksRules, Your script gives the following error : 21:44:01.967 - Players.superXcarlox2.Backpack.Tool.RemoteEvents.ClientFire:8: invalid argument #1 to 'ipairs' (table expected, got Instance)

0

You'd do 'players:GetPlayers()' to fix that error. You may as well just use FireAllClients instead.

I must thank RhyRocksRules for the help, but in the first line the script should've done players:GetPlayers() , Which I thank xinfinityBear for the help, I'll leave the script here for anyone who might need it.

local UnequipEvent = game.ReplicatedStorage.Folder.Unequipped
local Tool = script.Parent.Parent
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer


Tool.Unequipped:Connect(function()
	local players = game.Players:GetPlayers()
	for i, v in ipairs(players) do
	UnequipEvent:FireClient(players:GetPlayers())
	print("Yes")
	end

	end)

This discussion is preserved as it was. New answers, comments, and votes are closed.