Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
1local DistanceCheck = GlobalFunctions["DistanceCheck"](Character, 60)
2 
3if DistanceCheck ~= false then
4    local PlrsInDistance = Players:GetPlayerFromCharacter(DistanceCheck)
5 
6    Remote:FireClient(PlrsInDistance, Character, Hit)
7end

DistanceCheck:

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

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?

0
The error is probably in the DistanceCheck function ArvidSilverlock 50 — 4y
0
When setting plrdistance you may have to do v.Name not just v tjtorin 172 — 4y
0
^in your distance check tjtorin 172 — 4y

1 answer

Log in to vote
0
Answered by
DemGame 271 Moderation Voter
4 years ago
Edited 4 years ago

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

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

, Try using

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

instead.

Ad

Answer this question