Hi, so, I'm making a game where if you touch a part, a GUI becomes visible. I get an error that says FireClient: player argument must be a Player object
Could I possibly get some help? Any answer that works will do. It's a workspace script inside of the part. Also, if you were wondering, I have the GUI LocalScript in the target GUI, so that one isn't a problem. Here's the script that I have:
01 | local remEvent = game.ReplicatedStorage:WaitForChild( "RemoteEvent3" ) |
02 |
03 | local debounce = false |
04 |
05 | script.Parent.Touched:Connect( function (player) |
06 |
07 | if not debounce then |
08 |
09 | debounce = true |
10 |
11 | remEvent:FireClient(player) |
12 |
13 | wait( 999.999 ) |
14 |
15 | debounce = false |
16 |
17 | end |
18 |
19 | end ) |
the hit isnt the player, its the object that touched it; use this
01 | local remEvent = game.ReplicatedStorage:WaitForChild( "RemoteEvent3" ) |
02 |
03 | local debounce = false |
04 |
05 | script.Parent.Touched:Connect( function (hit) |
06 | local player = game.Players:getPlayerFromCharacter(hit.Parent) |
07 | if player then |
08 | if not debounce then |
09 | debounce = true |
10 | remEvent:fireClient(player) |
11 | end |
12 | end |
13 | end ) |
So the problem is that you can't get the player through a touched event. Because when you write player, the game automatically thinks you're referring to the part that got touched. So what you woul need to do is this
01 | local remEvent = game.ReplicatedStorage:WaitForChild( "RemoteEvent3" ) |
02 |
03 | local debounce = false |
04 |
05 | script.Parent.Touched:Connect( function (hit) |
06 | local Humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
07 | if Humanoid then |
08 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
09 |
10 |
11 | if not debounce then |
12 |
13 | debounce = true |
14 |
15 | remEvent:FireClient(Player) |