Can somenoe tell me why my script is not working

Where did you put the script then?

3 Likes

StarterCharacterScripts (extra letter)

Error = CanCollide is not a valid member of Model “Workspace.TeamDoor” - Client - LocalScript:8

3 Likes

it might be because it’s not a part or smth?

3 Likes
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")

local function ChangeCollisionProperty()
	for _,part in TeamDoor:GetDescendants() do
		if part:IsA("BasePart") then
			part.CanCollide = player.Team ~= teams.Business
		end
	end
end
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)

There

2 Likes

it’s still not working but the error disappeared

2 Likes

Then your team isn’t the right one.

local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")

local function ChangeCollisionProperty()
	for _,part in TeamDoor:GetDescendants() do
		if part:IsA("BasePart") then
			part.CanCollide = player.Team ~= teams.Business and player.Team ~= teams.Comfort
		end
	end
end
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)
2 Likes

image

2 Likes

I also joined thru every team and still didn’t work

2 Likes

well aren’t you a helpful one

it’s good to see you socialize!


riiiight

are you suuureee your teams are correct?? is the player on the right team?
can you put some sort of print into that function just incase it doesn’t work?

:grin:

damn she replied before me :broken_heart:

2 Likes

like that?

2 Likes

2 Likes

image
image

that is infact, not inside the function!

2 Likes
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")

local function ChangeCollisionProperty()
	print("smth")  -- I've moved the print statement inside this function
	for _,part in TeamDoor:GetDescendants() do
		if part:IsA("BasePart") then
			part.CanCollide = player.Team ~= teams.Business and player.Team ~= teams.Comfort
		end
	end
end

ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)
2 Likes

Alright test this:

local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")

local function ChangeCollisionProperty()
	for _,part in TeamDoor:GetDescendants() do
		if part:IsA("BasePart") then
			print("huh")
			part.CanCollide = not (tostring(player.Team) == "Business" or tostring(player.Team) == "Comfort")
		end
	end
end
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)
2 Likes

still not working eqeqqdwdqwewqedqsdq

2 Likes

I think you are wrong. It works. I tested it myself around 5 seconds ago.

Can you show me where the script is placed?

2 Likes

image

3 Likes

Place it in StarterPlayerScripts.

3 Likes

still not working i’m literally ramming the door

2 Likes

i’m just grasping straws here

are you ABSOLUTELY sure the player is on the RIGHT team??

literally sometihng wrong on your side

2 Likes