"Team" is not a valid member of DataModel?

Trying to make a script that stops players harming their owns team’s ships but I keep getting this error. What is a DataModel?

Team is a BrickColor value that lets the script know what team the ship is on

Script:

ball = script.Parent
damage = 100
local ship = script.Parent.Parent.Parent

function onTouched(hit)


local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid~=nil then
	tagHumanoid(humanoid)
	humanoid.Health = humanoid.Health - damage
	wait(2)
	untagHumanoid(humanoid)
	connection:disconnect()
else
	damage = damage / 2
	if damage < 2 then
		connection:disconnect()
		ball.Parent = nil
	end
end

if hit.ClassName == "Part" or hit.ClassName == "UnionOperation" then
	print(hit.Name)
	if hit.Parent:FindFirstChild("Team") or hit.Parent.Parent:FindFirstChild("Team") or hit.Parent.Parent.Parent:FindFirstChild("Team")  then
		if not hit.Parent.Team.Value == ship.Team.Value or not hit.Parent.Parent.Team.Value == ship.Team.Value or not hit.Parent.Parent.Parent.Team.Value == ship.Team.Value then
		local explosion = Instance.new("Explosion")
		explosion.BlastRadius = 5
		explosion.BlastPressure = 100000 -- these are really wussy units
		explosion.Position = script.Parent.Position
		explosion.Parent = game.Workspace
		connection:disconnect()
		ball.Parent = nil
		end
		
		
	
	
		
	end
end
end

function tagHumanoid(humanoid)
	-- todo: make tag expire
	local tag = ball:findFirstChild("creator")
	if tag ~= nil then
		local new_tag = tag:clone()
		new_tag.Parent = humanoid
	end
end


function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then
			tag.Parent = nil
		end
	end
end

connection = ball.Touched:connect(onTouched)

r = game:service("RunService")
t, s = r.Stepped:wait()
d = t + 5.0 - s
while t < d do
	t = r.Stepped:wait()
end

ball.Parent = nil
1 Like

Nevermind i found the problem. It was because the script was disabled and it wasn’t enabled until it was in a different parent.

I’ll answer your question anyway, so people know.

The DataModel is the root for the parent-child hierarchy (as described by the Wiki). You know the variable you use in your code game? game is a variable used to access the DataModel, just like workspace is for the Workspace service.