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

What do I do? - 16:52:59.829 - IsInGroup is not a valid member of Players?

Asked by
AltNature 169
5 years ago
Edited 5 years ago

So, Still making a script for my friend. Now, My script isn't working at all! :( No output errors.

It is a normal script located in Workspace > TouchPart

UPDATED :

game.Workspace.TouchPart.Touched:Connect(function(hit)

-- I will ignore your other code for now
 local part = script.Parent
 local debounce = false

if hit.Parent:FindFirstChild("Humanoid") then -- will tell you if what hit it is a player
local players = game:GetService("Players")
local plar = players:GetPlayerFromCharacter(hit.Parent) -- getting the player from the players service by providing the character.

 if plar:IsInGroup(3467972) then
       if not debounce then
    debounce = true

    wait(1) 
     part.BrickColor = BrickColor.Green()
else
    part.BrickColor = BrickColor.Red()
end
debounce = false
    end
    end
end)


0
No it should not be a local script User#21908 42 — 5y

2 answers

Log in to vote
0
Answered by
seith14 206 Moderation Voter
5 years ago
Edited 5 years ago

You first have to Check if there's a Humanoid, then find the player from game:GetService("Players")

local Part = script.Parent
local debounce = true
local players = game:GetService("Players")
local groupid = 3467972

script.Parent.Touched:Connect(function(hit) -- This Would be easier by placing the script inside the part
     if debounce and hit.Parent:FindFirstChild("Humanoid") and players:FindFirstChild(hit.Parent.Name) then -- Checks if theirs a Humanoid
    debounce = false
    local plar = players:FindFirstChild(hit.Parent.Name)
   if plar:IsInGroup(groupid) then
    print(plar.Name.." Is In Group:"..groupid)
    wait(1) 
     part.BrickColor = BrickColor.Green()
else
    part.BrickColor = BrickColor.Red()
end
debounce = true
end

end)

Make sure you place this script inside the part.

Ad
Log in to vote
0
Answered by 5 years ago

Ok so here we go:

game.Workspace.TouchPart.Touched:Connect(function(hit)
-- I will ignore your other code for now

    if hit.Parent:FindFirstChild("Humanoid") -- will tell you if what hit it is a player
        local players = game:GetService("Players")
        local plar = players:GetPlayerFromCharacter(hit.Parent) -- getting the player from the players service by providing the character.
        if if plar:IsInGroup(3467972) then

I hope this helps and have a great day scripting!

0
does it have to be a local script? AltNature 169 — 5y

Answer this question