I have a script that detect’s when its touched and then will deal damage if it has a humanoid, but its not dealing damage and not even detecting that it touched.
Script:
local debounce = false
local damage = 20
game.Players.PlayerAdded:Connect(function(plr)
script.Parent.Touched:Connect(function(hit)
print('works')
if hit.Parent:FindFirstChild('Humanoid') and debounce == false and hit.Parent.Name ~= plr.Name then
print('works AGAIN')
debounce = true
hit.Parent.Humanoid.Health -= damage
print('works perfectly')
task.wait(5)
debounce = false
end
end)
end)
--//Variables
local Part = script.Parent
--//Controls
local Damage = 20
--//Tables
local DamageDebounces = {}
--//Functions
Part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if not Humanoid or DamageDebounces[Humanoid] then
return
end
DamageDebounces[Humanoid] = true
Humanoid.Health -= Damage
task.wait(5)
DamageDebounces[Humanoid] = nil
end)
local tweenservice = game:GetService('TweenService')
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
game.ReplicatedStorage.Remotes.MousepOSITION.OnServerEvent:Connect(function(player, mousep)
local char = player.Character
if not char or not mousep then
return
end
local clone = game.ReplicatedStorage.IceCube:Clone()
clone.CFrame = char.LowerTorso.CFrame
clone.Position = Vector3.new(clone.Position.X, 40, clone.Position.Z)
clone:SetAttribute("Owner", player.UserId)
clone.Parent = char
print('oh yeah')
local tween = tweenservice:Create(clone, tweeninfo, {Position = mousep.Position})
tween:Play()
player.stats.Stamina.Value -= 15
print('tween played')
tween.Completed:Wait()
print('tween completed')
local hitboxclone = game.ReplicatedStorage.HitBox:Clone()
hitboxclone.Position = clone.Position
hitboxclone.Parent = clone
local explosion = Instance.new('Explosion')
explosion.BlastRadius = 10
explosion.Parent = clone
local smoke = game.ReplicatedStorage.Ice:Clone()
smoke.Parent = clone
clone:Destroy()
print('destroyed')
end)
And your other script to this:
--//Services
local Players = game:GetService("Players")
--//Variables
local Part = script.Parent
--//Controls
local Damage = 20
--//Tables
local DamageDebounces = {}
--//Functions
Part.Touched:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player and Part:GetAttribute("Owner") == Player.UserId then
return
end
local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if not Humanoid or DamageDebounces[Humanoid] then
return
end
DamageDebounces[Humanoid] = true
Humanoid.Health -= Damage
task.wait(5)
DamageDebounces[Humanoid] = nil
end)
Add a string value into the tool handle/hitbox and name it “who” or something
then in the summoning script, change the who value to the player name
In the hit script, detect if the person hit is the who value, and if true then ignore that hit.
Hope I’m not confusing lol