[Help] Scripting help

I am trying to create a script basically to detect if the player is in group once he touch the brick I already got most part of the code, but I have no idea of how to add the PlayerIsInGroup() Part, anyone got any idea?

This is the code so far

4 Likes

GetHoleingroup(GROUPID) i think its this

but you can use : Player:IsInGroup

Alright, thank you for the help, I’ll try that.

1 Like

You can only use LocalPlayer from a LocalScript, but your .Touched event should be done from the server, not the client. That said, you can do everything you want to accomplish from the server. There are many methods available to you to figure out who the player that is touching the part is. One such way is by using the :GetPlayerFromCharacter() method.

You can use the IsInGroup() method to check whether or not a player is in a group.

Your code should look something like this:

local detect = script.Parent
local debounce = false
local groupId = 12344--ID OF THE GROUP


detect.Touched:Connect(function(hit)
	if debounce then return end
	if(game.Players:GetPlayerFromCharacter(hit.Parent)) then --Part that hit the part is indeed a player
		debounce = true
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		print(player.Name)
		if (player:IsInGroup(groupId)) then
			print("in the group")
		end
		wait(5)
		debounce = false
	end
end)
2 Likes

Don’t forget to press the ‘Solution’ button for an answer that worked! :wink:

3 Likes