Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to define the Client?

sorry for the "spam" as I've asked two questions in a short space of time, but I was wondering how I would define the Client in this script:

local disableControlsRE = game:GetService("ReplicatedStorage"):FindFirstChild("DisableControls")


local player = game.Players.LocalPlayer -- this is what I have currently, and it doesn't appear to firing the RemoteEvent 


script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		
		disableControlsRE:FireClient(player)
		
	end
end)

The Output I got back was "FireClient : player argument must be a Player object" Can anyone please help?

1 comment

0

Is this a local or server script. You cant use LocalPlayer for serverscripts

1 answer

✓ Accepted answer

You can use :GetPlayerFromCharacter() to get the client.

local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
-- You should put this inside of the if statement or else something that has no client can cause an error

This discussion is preserved as it was. New answers, comments, and votes are closed.