For context, im making a staff and im making it so when you click and are a certain distance from the target you click, it launches an orb at them dealing damage. The other script (the one that launches the orb) works properly, but this, the damage script, doesnt.
gif of the staff launching orb
local ignore = script:WaitForChild("Ignore") --Getting value under script
local part = script.Parent --Getting the part (the orb)
part.Touched:Connect(function(t)
if t.Parent:FindFirstChild("Humanoid") and t.Parent.Name ~= ignore.Value and t.Parent.Name ~= "Staff" then --Making sure target touched isnt staff or player using attack
t.Parent.Humanoid:TakeDamage(10) --dealing damage
part:Destroy()
elseif t.Parent.Parent:FindFirstChild("Humanoid") and t.Parent.Name ~= ignore.Value and t.Parent.Name ~= "Staff" then
t.Parent.Humanoid:TakeDamage(10)
part:Destroy()
end
end)
if you watched the gif, you will see the orb does go to them, but it doesnt damage.
here is the "fire" script if needed
local BasicAttackEvent = script.Parent:WaitForChild("BasicAttack")
local StaffFolder = game.ReplicatedStorage.Staff
local ts = game:GetService("TweenService")
BasicAttackEvent.OnServerEvent:Connect(function(p, target) --target is mouse.target
if target.Parent:FindFirstChild("Humanoid") then
local c = p.Character
local dist = (c.HumanoidRootPart.Position - target.Parent.HumanoidRootPart.Position).magnitude
if dist <= 50 then
if target.Name == "HumanoidRootPart" then
local aa = StaffFolder.BasicAttack:Clone()
aa.Parent = workspace
aa.Position = c.Staff.Handle.Position
local tinfo = TweenInfo.new(.7,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local tprop = {}
tprop.Position = target.Parent.HumanoidRootPart.Position
aa.Damage.Ignore.Value = p.Name
local tween = ts:Create(aa,tinfo,tprop)
tween:Play()
end
end
end
end)
keep in mind, the second script is working just fine.
output displays no errors
also im aware the staff and orb looks bad lol, it is a temporary model

1 comment
:TakeDamage is the same thing as that :/ didnt work tho