generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: onTouch messing up my script?

Previous Thread :: Next Thread 
NickPresents1 is not online. NickPresents1
Joined: 17 Aug 2014
Total Posts: 78
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 is not online. 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
NickPresents1 is not online. NickPresents1
Joined: 17 Aug 2014
Total Posts: 78
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
Snowskateer is not online. Snowskateer
Joined: 06 Dec 2011
Total Posts: 4647
19 Mar 2017 07:29 AM
have you connected the ontouch function?
Report Abuse
NickPresents1 is not online. NickPresents1
Joined: 17 Aug 2014
Total Posts: 78
19 Mar 2017 07:32 AM
^ Yeah.

pf.Touched:connect(onTouch)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image