So basically i have an axe and a tree with a NumberValue that's name is "Health" and when I slash with the axe and the head of the axe collides with the tree its supposed to do 5 dmg but it doesn't even detect the number value
script:
Properties = {
debounce = true, -- Leave this on true.
sound_fx = true, -- If you don't want sound to play when tool is activated set this to false.
anim_check = true, -- If you don't want animation to play when tool is activated set this to false.
ToolDrop = false, -- Set this to true if you want to be able to drop the tool by pressing BackSpace.
soundID = 6042531284, -- Sound Id.
AnimID = 6461572129, -- Your Animtion id.
debounce_lenght = 1, -- how long it will take before you can click again, aka cooldown so you can't spam click the tool.
soundDelay = 0.25, -- How long to wait before playing sound
enableTrail = true, -- Enable trail thing
trail = script.Parent.Head.Trail, -- the trail thing
damage = 5 -- how much dmg the thing does
}
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local BaseUrl = "rbxassetid://"
local anim = Tool:WaitForChild("Animation")
local Players = game:GetService("Players")
if Properties.sound_fx then
sound = Handle:WaitForChild("Sound")
sound.SoundId = BaseUrl .. Properties.soundID
sound.MaxDistance = 100
sound.RollOffMode = Enum.RollOffMode.InverseTapered
end
if Properties.anim_check then
anim.AnimationId = BaseUrl .. Properties.AnimID
end
if Properties.ToolDrop == true then
Tool.CanBeDropped = true
end
Tool.Equipped:Connect(function(Mouse) -- When you equip the tool
local player = Players:GetPlayerFromCharacter(Tool.Parent) -- gets the player
if Properties.anim_check == true then animation = player.Character.Humanoid:LoadAnimation(anim)end -- loads animation
Tool.Activated:Connect(function() -- when you click with the tool
if Properties.debounce then
Properties.debounce = false
if Properties.anim_check == true then animation:Play()end
if Properties.sound_fx == true then wait(Properties.soundDelay) sound:Play()end
if Properties.enableTrail == true then
Properties.trail.Enabled = true
wait(0.2)
Properties.trail.Enabled = false
end
script.Parent.Head.Touched:Connect(function(Hit)
print(Hit.Name)
if Hit:FindFirstChild("NumberValue") and Hit:FindFirstChild("NumberValue").Name == "Health" then
local temp = Hit:FindFirstChild("NumberValue")
print(temp.Name .. ": " .. temp.Value)
temp.Value = temp.Value - Properties.damage
end
end)
wait(Properties.debounce_lenght)
Properties.debounce = true
end
end)
end)
Tool.Unequipped:Connect(function()
if Properties.anim_check == true then animation:Stop()end
if Properties.sound_fx then sound:Stop()end
end)

3 comments
LocalScript or ServerScript?
Also is the name of the NumberValue “NumberValue”?
Server script and read the description