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 3 years ago
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?

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

1 answer

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

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.

Ad

Answer this question