What did I do wrong in my script?

local Groupservice = game:GetService("GroupService")
local GroupId = 4963920

script.Parent.Touched:Connect(function(Hit)
	local H = Hit.Parent:FindFirstChild("Humanoid")	
	if H then
		local player = game.Players:GetPlayerFromCharacter(Hit.Parent)	
		if player:IsInGroup(GroupId) then
			print("this player is in the group")
		else
			print("this player is not in the group")
		end	
	end
end)

what did i do wrong with my script ?

Are you getting an error? Is it just not working?
Explain what’s going wrong.

Question, is this a localscript?

Using this in a Script , as opposed to a LocalScript , will not get you the most up-to-date information. If a player leaves a group while they are in the game, IsInGroup will still think they’re in that group until they leave. However, this does not happen when used with a LocalScript.

You might want to use remotes here, to do the check on the client.

1 Like

yes, it is a local script :grinning:

Then that would explain why this doesn’t work since localscripts doesn’t work when they are a descendant of a workspace and not parented by a character model. Consider using a serverscript instead.

1 Like

i don’t see the print in the output

ok thx. :grinning: :grinning: :grinning:

and you too! :grinning: :grinning: