Hi, when I try to pass the player argument through FireClient it comes out with the error "FireClient: player argument must be a Player object", and I'm confused. Do I need to define the player beforehand for this to work?
Script
local function windows (player) if script.Parent.Occupant ~= nil then game.ReplicatedStorage.SeeThrough:FireClient(player) end end script.Parent.Touched:Connect(windows)
On the wiki, it shows that Touched returns one parameter, that is the part that touched, not the player object of the character that touched. To get the player object, you need to use GetPlayerFromCharacter, as shown below:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then --ensures that the part that touched is a character model and its a valid player’s character local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if script.Parent.Occupant ~= nil then game.ReplicatedStorage.SeeThrough:FireClient(Player) end end end)