local part = script.Parent --
local Debounce = false --(Cooldown)
local tool = script.Parent.Parent
if not tool.Activated then
return
end
part.Touched:Connect(function(OtherPart)
if not OtherPart:IsDescendantOf(workspace.misc_) then
return
end
if Debounce == false then
Debounce = true --Cooldown
local Char = game.Players.LocalPlayer.Character
local Humanoid = Char.Humanoid
Humanoid:TakeDamage(50)
task.wait()
Debounce = false
end --Debounce
end)
Local scripts dont work in the workspace, which is why nothing is happening. Try moving the part (script.Parent) into workspace and moving the local script into the tool and the tool into StarterPack
PS: You cannot check Tool.Activated like that since it’s an event, not a Boolean.
Try this revised script
-- Local script in tool in starter pack (Make sure there's a part "Handle" in the tool)
local part = workspace. Part --
local Debounce = false --(Cooldown)
local tool = script.Parent
local active
tool.Activated:Connect(function()
active = true
end)
tool.Deactivated:Connect(function()
active = false
end)
part.Touched:Connect(function(OtherPart)
if not OtherPart:IsDescendantOf(workspace.misc_) then
return
end
if Debounce == false and active then
Debounce = true --Cooldown
local Char = game.Players.LocalPlayer.Character
local Humanoid = Char.Humanoid
Humanoid:TakeDamage(50)
task.wait()
Debounce = false
end --Debounce
end)
If part is a child of tool, then it is only in workspace whenever the tool is equipped. The parent of tool is ‘backpack’, when it isn’t selected, which means the part can never be touched. When you equip a tool, it parents it to your character, so a descendant of workspace.
Also, ‘tool activated’ means something else: it’s an event which fires every time a player clicks, with an equipped tool. You’re looking for ‘tool.Equipped’