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

How should I damage players with my fireball?

Asked by
Ruves 21
4 years ago

Basically I've created a script that launches a fireball in-front of the player but I'm not entirely sure what would be the most effective way to damage other players with it.

Should I create a script and put it inside the fireball when it launches.. that would damage the player using .Touched.

Or should I use a .Touched function in my server script that create the fireball itself?

2 answers

Log in to vote
0
Answered by 4 years ago

I'd recommend using the .Touched event for the fireball like this.

script.Parent.Touched:Connect(function(touch)
    touch.Parent:FindFirstChild("Humanoid")
    if touch ~= nil then
        touch:TakeDamage(30)
        (or Something like that)
    end
end)

Im not too sure this would work but Ye, I hope this works for you!

0
Awesome! So it's better to have it in a second script inside the fireball instead of just using .Touched in the same script you create the part in? Ruves 21 — 4y
0
Are you talking about an Instance.new script and then putting the code inside of the same script? roblox136393 32 — 4y
0
uh let me see if I can explain it a little clearly. Ruves 21 — 4y
0
If you are then nah, In my opinion Create a second script as the child of the Instance script then in the instance script type in a code like "script.Parent."Damage Script".Parent = game.Workspace.Fireball roblox136393 32 — 4y
0
check my other comment c: Ruves 21 — 4y
Ad
Log in to vote
0
Answered by
Ruves 21
4 years ago

Basically,

Which one of these is better to use.

Script inside ServerScript that creates Fireball

p = Instance.new("Part")
p.Size = Vector3.new(2,2,2)

p.Parent = game.Workspace

p:Touched:Connect(function(touch)
    if touch.Parent:FindFirstChild("Humanoid") ~= nil then
        touch:TakeDamage(30)
    end
end)

OR

Script which has been copied into the Fireball itself.

p = script.Parent
p:Touched:Connect(function(touch)
    if touch.Parent:FindFirstChild("Humanoid") ~= nil then
        touch:TakeDamage(30)
    end
end)

Answer this question