The script is supposed to check if player is a player and if the player is a player then it sets all parts in the model to CanCollide = false, but if its not a player then it sets CanCollide = true for al the parts in the Model. All the parts in the Model are named Cannotdelete. Why is the script not working?

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local model = workspace.Grid.Model

for _, child in ipairs(model:GetChildren()) do
	if child:IsA("BasePart") then
		if player then
			child.CanCollide = false
		else
			child.CanCollide = true
		end
	end
end

3 comments

0

I don't understand you're problem. Are you trying to check if a player touched the model?

0

there are a bunch of parts in a model all of them are named Cannotdelete, I want to set all of the to CanCollide = false if a player touches the parts, but if anything else touches the part set CanCollide = true

0

nvm i solved it