|
| 19 Mar 2017 07:10 AM |
I am working on a flamethrower-like spell and everything works fine until I add a damage bit. My damage bit is:
local dmg = Instance.new('IntValue', pf) dmg.Name = "DamageV" dmg.Value = 10 function onTouch(part) local humanoid = part.Parent:findFirstChild("Humanoid") if (humanoid ~=nil) then humanoid:TakeDamage(dmg.Value) end end
This is in a loop and gets executed 15 times, the pf is a part that gets larger the more times the bit of code inside the loop is executed, its position is set by the position of a part that has BodyVelocity.
pf.CFrame = #########
The ## is that part with the BodyVelocity. Now for some reason, if I delete that damage bit everything works fine, however if I leave the damage bit in the flamethrower suddenly turns into 3 pillars of different sized parts. I am really confused as to why this is happening. Also if I try applying that damage script to the fb p##t#####j##t negates the body velocity and the part stays in place.
I don't need any alterations to my code just tell me why the heck this is happening. |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 19 Mar 2017 07:13 AM |
| Might be becuse you're calling a dmg value local and it's outside a function, try without the local part infront. |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 07:27 AM |
Nope, still the same problem.
I am confused though, why would a damage function make the position go wacky :/ |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 07:29 AM |
have you connected the ontouch function?
|
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 07:32 AM |
^ Yeah.
pf.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|