So in my game, i have 2 (1 is local, 1 is normal script) and i use remote function to check if any player is holding a key. However, when i run it, i always recieve the error that says : 11:58:34.338 - InvokeClient: player argument must be a Player object.
I think this means that it is saying i have to specify which player to invoke, but i want every client to return the answer. Or do i have to do this multiple time until it checks every player?
code(normal script)
local totemEye1 = script.Parent.eye1 local totoemEye2 = script.Parent.eye2 local players = game.Players local originalkeyTorch = game.ServerStorage:WaitForChild("keyTorch") local originalkeyPosition = originalkeyTorch.Handle.Position local keyTorchLostDetector = script.Parent.keyLostDetector local torchBackDetector = script.Parent.Parent.torch1Checker local keynotDestroyed = true local keylost = false local keytorchTimer = game.StarterGui.ScreenGui.keytorchtimer local playerDefine = game.Players:FindFirstChildOfClass("Player") keyTorchLostDetector.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then print("the visible key torch is about to get stealed by player") game.ReplicatedStorage.toolEquippedCheck:InvokeClient(player,keyequipped) if keyEquipped == true then for i = 10,0,-1 do wait(1) keytorchTimer.Text = "Bring the torch to totem pole in "..i if i < 1 then keylost = true end end keytorchTimer.Text = "" if keylost == true then keylost = false wait(10) hit.Parent:Destroy() local visiblekeyTorch = originalkeyTorch:Clone() visiblekeyTorch.Name = "visiblekeyTorch" visiblekeyTorch.Parent = game.Workspace end torchBackDetector.Touched:Connect(function(hit) if hit.Parent == "visiblekeyTorch" then keylost = false wait(10) hit.Parent:Destroy() local visiblekeyTorch = originalkeyTorch:Clone() visiblekeyTorch.Name = "visiblekeyTorch" visiblekeyTorch.Parent = game.Workspace end end) end end end)
code2(Local script)
local replicatedStorage = game:GetService("ReplicatedStorage") local toolequipCheck = replicatedStorage.toolEquippedCheck local player = game.Players.LocalPlayer local character = player.character local function toolEquippedcheck(keyequipped) local character = player.character local visiblekeyTorch = character:FindFirstChildWhichIsA("BackpackItem") if visiblekeyTorch then return true end end game.ReplicatedStorage.toolEquippedCheck.OnClientInvoke = toolequipCheck