Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need to deal damage with my wand/spell but not damage any players in the game?

Asked by 5 years ago

I'm looking for a way to deal no damage to players in the game but still be able to damage NPC's in the game. Please take a look below Also the orb should be deleted after touching an NPC or continuing on a path to nowhere. It should also only damage an NPC once.

local mouse = game.Players.LocalPlayer:GetMouse() local orbtouch = false script.Parent.UseWand.OnServerEvent:Connect(function(Player)

local Orb = game.ReplicatedStorage.Small:Clone()
Orb.CFrame = script.Parent.Parent.Handle.CFrame*CFrame.new(0 ,0, 0)
Orb.Parent = workspace
local BV = Instance.new("BodyVelocity", Orb)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = (mouse.hit.p - Orb.Position).unit * 65
BV.Parent = Orb

function onTouch(Orb) 
local humanoid = Orb.Parent:FindFirstChild("Humanoid") 
if (humanoid ~= nil) and humanoid.Parent ~= Player.Character then   -- if a humanoid exists, then
    humanoid.Health = humanoid.Health - 100
    orbtouch = true
end
if orbtouch == true then
    Orb.Destroy()
end 

Orb.Touched:connect(onTouch)


wait (2.5)
Orb:Destroy()



end

end)

0
um you cant clone stuff, set the cframe of stuff,or Instance.new stuff on a local script (I'm assuming this is local cause you used :GetMouse() and Localplayer) theking48989987 2147 — 5y
0
connect is deprecated, use Connect instead, it's mouse.Hit.p not mouse.hit.p ScrubSadmir 200 — 5y

Answer this question