Sorry for the weird title, if you want a quick TL:DR on this it is about:
18:36:38.974 - FireClient: player argument must be a Player object
I would really appreciate some help here
Okay so I have a brick:
"RemoveGui" and inside there there is a script
local brick = script.Parent brickClosedEvent = game.ReplicatedStorage.Event.BrickClose local debounce = false brick.Touched:Connect(function(hit) if not debounce then debounce = true print("activated") local player = game.Players:GetPlayerFromCharacter(hit.Parent) brickClosedEvent:FireClient(player) print("WorkingClose") wait(0.5) debounce = false end end)
And I have another brick called "AddGui" which will show the gui, whereas RemoveGui will close it whcih goes
local brick = script.Parent brickTouchedEvent = game.ReplicatedStorage.Event.BrickTouched local debounce = false brick.Touched:Connect(function(hit) if not debounce then debounce = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) brickTouchedEvent:FireClient(player) print("Working") wait(0.5) debounce = false end end)
And then in replicated storage I have a folder called "Event" and inside that two remote events which are called "BrickClose" and "BrickTouched"
And finally in StarterGui I have got a local script called "BrickGui" which has a Gui called "Gui" and a frame inside that called "Frame".
So the local script (BrickGui) goes:
local gui = script.Gui local brickTouchedEvent = game.ReplicatedStorage.Event.BrickTouched local brickCloseEvent = game.ReplicatedStorage.Event.BrickClose brickTouchedEvent.OnClientEvent:Connect(function() gui.Enabled = true print("open") end) brickCloseEvent.OnClientEvent:Connect(function() print("going to close") gui.Enabled = false end)
So what I am aiming for is that the two remote events will fire and the local gui will pick them up and do so accordingly.
However
What my problem is that when I touch AddGui it says, "18:36:38.974 - FireClient: player argument must be a Player object"
I have read other articles on this but I can't really grasp what I should do.
I would really appreciate some help here, Thanks
What you're doing wrong inside your script is that you're not checking if the part that's touching it is a child of the character.
Here's how u can check that :
brick.Touched:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') and not debounce then debounce = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) brickTouchedEvent:FireClient(player) print("Working") wait(0.5) debounce = false end end)
You can make the gui visible/invisible not removing or creating.That might fix your problem