Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I add a creator tag to this?

Asked by 3 years ago

I'm new to scripting and don't really understand the creator tags

local tool = script.Parent

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack
local swingAnim = script:WaitForChild("Swing")
local swingAnimTrack

local slashSound = script:WaitForChild("SlashSound")
local sheathSound = script:WaitForChild("SheathSound")
local hitSound = script:WaitForChild("HitSound")

local hitCharacters = {}
local debounce = false


tool.Equipped:Connect(function()

    local humanoid = script.Parent.Parent.Humanoid
    if not idleAnimTrack then idleAnimTrack = humanoid:LoadAnimation(idleAnim) end

    idleAnimTrack:Play()

    sheathSound:Play()
end)
tool.Unequipped:Connect(function()

    if idleAnimTrack then idleAnimTrack:Stop() end
    if swingAnimTrack then swingAnimTrack:Stop() end

    sheathSound:Play()
end)
tool.Activated:Connect(function()

    if debounce then return end
    debounce = true

    local humanoid = script.Parent.Parent.Humanoid
    if not swingAnimTrack then swingAnimTrack = humanoid:LoadAnimation(swingAnim) end

    swingAnimTrack:Play()

    wait(0.5)   
    slashSound:Play()

    wait(0.5)
    debounce = false
end)
tool.Blade.Touched:Connect(function(touch)

    if hitCharacters[touch.Parent] or not debounce then return end
    if touch.parent:FindFirstHumanoid("Players") then return end
    if touch.Parent:FindFirstChild("Humanoid") then

        if touch.Name == "Head" then
            touch.Parent.Humanoid:TakeDamage(4)
        else
            touch.Parent.Humanoid:TakeDamage(3)
        end
        hitSound:Play()
        hitCharacters[touch.Parent] = true
        wait(1)
        hitCharacters[touch.Parent] = nil
    end
end)

I'm new to scripting and don't really understand the creator tags

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Destroy all existing tags & add a new one with the player as a value. The creator tag is an ObjectValue.

local function TagHumanoid(Attacker: Player, Target: Humanoid)
    for index, value in pairs(Humanoid:GetChildren()) do
        if value:IsA("ObjectValue") and string.lower(value.Name) == "creator" then
            value:Destroy()
        end
    end
    local ObjectValue = Instance.new("ObjectValue")
    ObjectValue.Name = "creator"
    ObjectValue.Value = Attacker
    ObjectValue.Parent = Humanoid
end
Ad

Answer this question