I had a problem where and how to write a script on
tag system. My tool uses 3 scripts:
IdleScript
script.Parent.Activated:Connect(function()
script.Disabled = true
local animation = script.Animation
local humanoid = script.Parent.Parent.Humanoid
local animationtrack = humanoid:LoadAnimation(animation)
animationtrack:Play()
script.Parent.Handle.Script.Disabled = false
wait(0.1)
script.Disabled = false
script.Parent.Handle.Script.Disabled = true
end)
script.Parent.Equipped:Connect(function()
local idle = script.idle
local humanoid = script.Parent.Parent.Humanoid
local animationtrack = humanoid:LoadAnimation(idle)
animationtrack:Play()
end)
script.Parent.Unequipped:Connect(function()
local humanoid = script.Parent.Parent.Parent.Character.Humanoid
local animtracks = humanoid:GetPlayingAnimationTracks()
for i, track in pairs(animtracks) do
track:Stop()
end
end)
script.Parent.Activated:Connect(function()
script.Disabled = true
local idle = script.idle
local Animation = script.Animation
local humanoid = script.Parent.Parent.Humanoid
local animationtrack = humanoid:LoadAnimation(Animation)
animationtrack:Play()
local animtracks = humanoid:GetPlayingAnimationTracks()
for i, track in pairs(animtracks) do
track:Stop()
end
script.Parent.Handle.Script.Disabled = false
wait(2)
script.Disabled = false
script.Parent.Handle.Script.Disabled = true
local animationtrack2 = humanoid:LoadAnimation(idle)
animationtrack2:Play()
end)
AnimationScript
script.Parent.Activated:Connect(function()
script.Disabled = true
local animation = script.Animation
local humanoid = script.Parent.Parent.Humanoid
local animationtrack = humanoid:LoadAnimation(animation)
animationtrack:Play()
script.Parent.Handle.Script.Disabled = false
wait(0.1)
script.Disabled = false
script.Parent.Handle.Script.Disabled = true
end)
Handle - Script
function OnTouch(hit)
script.Disabled = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid.Health = humanoid.Health - 5
end
script.Parent.Touched:Connect(OnTouch)
I have a script on Tag but I don’t know where to put it and how
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
game:GetService("Debris"):AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
As additional information to the problem: I use this script for cash per kill
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("NumberValue")
cash.Name = "Cash"
cash.Parent = leaderstats
player.CharacterAdded:Connect(function(Chr)
Chr.Humanoid.Died:Connect(function(Died)
local creator = Chr.Humanoid:FindFirstChild("creator")
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator ~= nil and creator.Value ~= nil then
leaderstats.Cash.Value = leaderstats.Cash.Value + 10
end
end)
end)
end)