My code is a brick that you touch to open a gui then you touch another to close it?
Asked by
4 years ago Edited 4 years ago
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
01 | local brick = script.Parent |
02 | brickClosedEvent = game.ReplicatedStorage.Event.BrickClose |
05 | brick.Touched:Connect( function (hit) |
09 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
10 | brickClosedEvent:FireClient(player) |
And I have another brick called "AddGui" which will show the gui, whereas RemoveGui will close it whcih goes
01 | local brick = script.Parent |
02 | brickTouchedEvent = game.ReplicatedStorage.Event.BrickTouched |
05 | brick.Touched:Connect( function (hit) |
08 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
09 | brickTouchedEvent:FireClient(player) |
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:
02 | local brickTouchedEvent = game.ReplicatedStorage.Event.BrickTouched |
03 | local brickCloseEvent = game.ReplicatedStorage.Event.BrickClose |
06 | brickTouchedEvent.OnClientEvent:Connect( function () |
11 | brickCloseEvent.OnClientEvent:Connect( function () |
12 | print ( "going to close" ) |
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