For some reason my code is working in studio but not in-game. I've been stumped on this for awhile now. The sword is supposed to tag a mob, then when the mob dies it awards the player with gold. But it doesnt work in-game
Heres the sword code; `
local tool = script.Parent local handle = tool.Union local cooldown = 0.45 local plr = game.Players.LocalPlayer tool.Activated:Connect(function() if swinging then return end swinging = true wait(cooldown) if swinging then swinging = false end end) handle.Touched:Connect(function(hit) if swinging then swinging = false print("hit") local humanoid = hit.Parent:FindFirstChild('Enemy') if not humanoid then return end local tag = Instance.new('ObjectValue',humanoid) tag.Name = 'creator' tag.Value = plr humanoid:TakeDamage(12) wait(0.45) tag:Destroy() end end)`
Heres the reward code: `
local reward = 5 local npc = script.Parent local human = npc.Enemy human.Died:Connect(function() local tag = script.Parent.Enemy:FindFirstChild('creator') local killer = tag.Value killer.Data.Stats.Gold.Value = killer.Data.Stats.Gold.Value + reward end)