--[[ LawlR fix ]]
--

local ds = game:GetService("Debris")
local ps = game:GetService("Players")

local rng = Random.new()

local star = script.Parent
local starOwner = star:WaitForChild("Owner").Value
local hitSound = star.Hit

local ownerName = starOwner.Name
local dmg = 23
local lifetime = 10

local stuck


local function tagHum(hum)
	local tag = Instance.new("ObjectValue")
	tag.Name = "creator"
	tag.Value = starOwner
	tag.Parent = hum
	ds:AddItem(tag, 2)
end

local function isTeamMate(hitPlr)
	return (hitPlr and starOwner and not hitPlr.Neutral and not starOwner.Neutral and hitPlr.TeamColor == starOwner.TeamColor)
end

local function weld(obj, hit)
	local Weld = Instance.new("Weld")
	Weld.Part0 = obj
	Weld.Part1 = hit
	local HitCFrame = CFrame.new(obj.Position)
	Weld.C0 = obj.CFrame:ToObjectSpace(HitCFrame)
	Weld.C1 = hit.CFrame:ToObjectSpace(HitCFrame)
	Weld.Parent = obj
end


star.Touched:Connect(function(hit)
	if not stuck then
		weld(star, hit)
		stuck = true
		hitSound:Play()
		
		local hitHum = hit.Parent:FindFirstChildWhichIsA("Humanoid") or hit.Parent.Parent:FindFirstChildWhichIsA("Humanoid")
		if hitHum and hitHum.Health > 0 then
			local hitChr = hitHum.Parent
			if hitChr then
				if hitChr.Name ~= ownerName then
					local hitPlr = ps:GetPlayerFromCharacter(hitChr)
					if hitPlr and isTeamMate(hitPlr) then
						return
					end
					tagHum(hitHum)
					hitHum:TakeDamage(dmg * ((hitChr:FindFirstChild("NinjaMaskOfShadows") and 2) or 1))
				end
			end
		end
	end
end)

ds:AddItem(star, lifetime)
