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?
I'd recommend using the .Touched event for the fireball like this.
1 | script.Parent.Touched:Connect( function (touch) |
2 | touch.Parent:FindFirstChild( "Humanoid" ) |
3 | if touch ~ = nil then |
4 | touch:TakeDamage( 30 ) |
5 | ( or Something like that) |
6 | end |
7 | end ) |
Im not too sure this would work but Ye, I hope this works for you!
Basically,
Which one of these is better to use.
Script inside ServerScript that creates Fireball
01 | p = Instance.new( "Part" ) |
02 | p.Size = Vector 3. new( 2 , 2 , 2 ) |
03 |
04 | p.Parent = game.Workspace |
05 |
06 | p:Touched:Connect( function (touch) |
07 | if touch.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
08 | touch:TakeDamage( 30 ) |
09 | end |
10 | end ) |
OR
Script which has been copied into the Fireball itself.
1 | p = script.Parent |
2 | p:Touched:Connect( function (touch) |
3 | if touch.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
4 | touch:TakeDamage( 30 ) |
5 | end |
6 | end ) |