Group Collision Wall

Hello! So I wanted to make an invisible wall where if a player is the met rank then it will turn CanCollide off, and if they arent CanCollide will be on! I don’t know what’s going on though, please help!

Script:

local GroupID = 11941815
local Player = game.Players.LocalPlayer

game.Workspace.StageWall.Touched:Connect(function(hit)
	if Player:GetRankInGroup(GroupID) == 255 or Player:GetRankInGroup(GroupID) == 14 and hit.Parent == Player then
		game.Workspace:WaitForChild("StageWall").CanCollide = false
	else
		if Player:GetRankInGroup(GroupID) <= 3 then
			game.Workspace:WaitForChild("StageWall").CanCollide = true
		end
	end
end)

Please Help!
1 Like

This will not work, since hit.Parent will be the player’s character, not the player itself. By the way assuming this is a LocalScript, change it to a Script on ServerScriptService and try this:

local Players = game:GetService("Players")

local StageWall = workspace:WaitForChild("StageWall")

local GroupID = 11941815

StageWall.Touched:Connect(function(hit : Instance)
	if hit then
		if hit.Parent:FindFirstChild("Humanoid") then
			local Client : Player = Players:GetPlayerFromCharacter(hit.Parent)

			if Client:GetRankInGroup(GroupID) == 255 or Client:GetRankInGroup(GroupID) == 14 then
				StageWall.CanCollide = false
			else
				if Client:GetRankInGroup(GroupID) <= 3 then
					StageWall.CanCollide = true
				end
			end
		end
	end
end)

It was a Script in ServerScriptService. Thanks for pointing that hit.Parent won’t work! :slight_smile:

Then, also this will not work, since you can only access the LocalPlayer by a LocalScript.

Got it! Thanks so much, you always are a big help!

1 Like