Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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?

0
UnequipEvent:FireClient(player) raid6n 2196 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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!

0
In that case, woudn't it be better if you use UnequipEvent:FireAllClients() ? Leamir 3138 — 4y
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) superxcarlox2 3 — 4y
0
You'd do 'players:GetPlayers()' to fix that error. You may as well just use FireAllClients instead. xInfinityBear 1777 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)

Answer this question