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

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

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)


1 comment

0

No it should not be a local script

2 answers

✓ Accepted answer

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.

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!

1 comment

0

does it have to be a local script?

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