This is my third time having asked for some help with creator tags, upon the other times of asking I have been given the answer, I need to do it through the server. My question is how would I determine the player doing damage be the value of the tag, given I can't use game.Players.LocalPlayer

local TOOL = script.Parent
local BLADE = TOOL.Blade
local HANDLE = TOOL.Handle
local ANIMS = {}
for index, CHILD in pairs(script:GetChildren()) do
	if CHILD.Name == "Slash" then
		table.insert(ANIMS,CHILD)
	end
end
local FIGHT = false
local FRIENDLYFIRE = TOOL.FriendlyFire
local IDLEANIM = nil
local TRAIL = BLADE.Trail
local PLAYER = --What should this be?

function Slash()
	if FIGHT == false then
		local HUM = TOOL.Parent:FindFirstChildOfClass("Humanoid")
		if HUM then
			TOOL.Slashing.Value = true
			BLADE.Swing.Pitch = math.random(8,12)/10
			BLADE.Swing:Play()
			TRAIL.Enabled = true
			local SHOUT = script.Grunt:Clone()
			SHOUT.Parent = HUM.Torso
			SHOUT:Play()
			SHOUT.Pitch = math.random(8,12)/10
			game:GetService("Debris"):AddItem(SHOUT,2)
			local BOD = Instance.new("BodyPosition",HUM.Torso)
			BOD.Position = HUM.Torso.CFrame * CFrame.new(0,0,-6).p
			BOD.P = 750
			BOD.D = 35
			BOD.MaxForce = BOD.MaxForce*25
			local ANIM = HUM:LoadAnimation(ANIMS[math.random(1,#ANIMS)])
			ANIM:Play()
			FIGHT = true
			local HIT = BLADE.Touched:Connect(function(TOUCHED)
				if TOUCHED.Parent:FindFirstChildOfClass("Humanoid") then
					local HUM = TOUCHED.Parent:FindFirstChildOfClass("Humanoid")
					local PASS = true
					if game.Players:FindFirstChild(HUM.Parent.Name) and FRIENDLYFIRE.Value == false and TOUCHED.Parent:FindFirstChildOfClass("ForceField") == nil then
						PASS = false
					end
					if PASS == true then
						UntagHumanoid(HUM)
						TagHumanoid(HUM,PLAYER)
						HUM:TakeDamage(TOOL.Damage.Value)
					end
				end
			end)
			ANIM.Stopped:Connect(function()
				TOOL.Slashing.Value = false
				BOD:Remove()
				TRAIL.Enabled = false
				HIT:Disconnect()
				wait()
				FIGHT = false
			end)
		end
	end
end

local Debris = game:GetService("Debris")

function TagHumanoid(HUM,PLAYER)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = PLAYER
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = HUM
end

function UntagHumanoid(HUM)
	for i, v in pairs(HUM:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			wait(15)
			v:Destroy()
		end
	end
end

TOOL.Activated:Connect(function()
	Slash()
end)

TOOL.Equipped:Connect(function()
	local HUM = TOOL.Parent:FindFirstChildOfClass("Humanoid")
	if HUM and script:FindFirstChild("Idle") then
		IDLEANIM = HUM:LoadAnimation(script.Idle)
		IDLEANIM:Play()
	end
end)
TOOL.Unequipped:Connect(function()
	if IDLEANIM then
		IDLEANIM:Stop()
	end
end)

I am using this tagging system to award a player upon killing something.

2 comments

0

You can try using Game:GetService("Players").LocalPlayer, I'm not sure if it'll work as intended but in my server scripts that's what I'm using.

0

If this is a tool then PLAYER should just be game.Players:GetPlayerFromCharacter(script.Parent.Parent). This will get the player in the game.Players list.