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

Firing client only if a player is in a certain area not working?

local DistanceCheck = GlobalFunctions["DistanceCheck"](Character, 60)

if DistanceCheck ~= false then
	local PlrsInDistance = Players:GetPlayerFromCharacter(DistanceCheck)
			
	Remote:FireClient(PlrsInDistance, Character, Hit)
end

DistanceCheck:

		for _,v in pairs(workspace:GetChildren()) do
			if v ~= Character and v:FindFirstChild("HumanoidRootPart") 
				and (Character.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude <= Range then
				local plrindistance = game.Players:FindFirstChild(v)
				return plrindistance
			end
		end

Error: 12:39:04.987 - FireClient: player argument must be a Player object

I'm trying to make it so if only player's are in a 60stud range it will fireclient for effects. But i'm having trouble. Could someone help me out?

3 comments

0

The error is probably in the DistanceCheck function

0

When setting plrdistance you may have to do v.Name not just v

0

^in your distance check

1 answer

On the distance check script, I think your error is on line 4. Instead of using

local plrindistance = game.Players:FindFirstChild(v)

, Try using

local plrindistance = game.Players:FindFirstChild(v.Name)

instead.

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