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 » Scripting Helpers
Home Search
 

Re: Touched event not detecting touches

Previous Thread :: Next Thread 
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 03:06 AM
I'm trying to make a nuke, but I found out that the explosion sphere isn't detecting touches from bricks other than the players.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 03:09 AM
You can check each players magnitude, or use region3.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 03:15 AM
How will that help the explosion sphere detect touches from non-humanoid parts?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 03:16 AM
Then use region3, thought it will have cubical collosion zone.
Report Abuse
harryx is not online. harryx
Joined: 25 Oct 2008
Total Posts: 3209
05 Apr 2013 03:18 AM
Umm, get a table of all the parts in workspace and check for distance every second.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 03:28 AM
Ouch, that would make a large game very laggy. Really wished there was a way for the Touched event to do the detection.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 03:28 AM
Ew no, don't. This is one of few times when you should use region3.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 03:43 AM
Might as well make the explosion sphere a cube now, LOL.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 03:47 AM
Well just have ball and cubical collision. Simply say that it is shock wave.

Well you can check distance for detected parts, so it's like hybrid - region3 and magnitude check.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 04:05 AM
This is my original script:
==========
script.Parent.Touched:connect(function(Touched)
print(Touched)
if Touched.Anchored == true then
Touched.Anchored = false
end
Touched:BreakJoints()

local Thrust = Instance.new("BodyThrust",Touched)
local ThrustFactor = 100
local NukeCFrame = script.Parent.CFrame
local Xforce,Yforce,Zforce = 0,0,0
if Touched.CFrame ~= nil then
if NukeCFrame.x - Touched.CFrame.x < 0 then
Xforce = -1 * ThrustFactor
elseif NukeCFrame.x - Touched.CFrame.x > 0 then
Xforce = ThrustFactor
end
if NukeCFrame.y - Touched.CFrame.y < 0 then
Yforce = -1 * ThrustFactor
elseif NukeCFrame.y - Touched.CFrame.y > 0 then
Yforce = ThrustFactor
end
if NukeCFrame.z - Touched.CFrame.z < 0 then
Zforce = -1 * ThrustFactor
elseif NukeCFrame.z - Touched.CFrame.z > 0 then
Zforce = ThrustFactor
end
end
Thrust.force = Vector3.new(Xforce,Yforce,Zforce)
end)
==========
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 04:09 AM
Don't use body thrust. Simply set Velocity like:

part.Velocity = (nuke.Position-part.Position).unit*500

Make sure to sit people, if you detect humanoid.
Report Abuse
DeathLicht is not online. DeathLicht
Joined: 06 Jun 2011
Total Posts: 340
05 Apr 2013 04:13 AM
this is common.. i will tell you what is happening..

Parts have an "Joint" to an anchored part... in this case could be a building with joints to "BasePlate" than is anchored..

try to test it on Parts without "Joints" to an anchored part
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 04:18 AM
Wow, that simplified the script very much. I'm still trying to find a simple way to detect object touches before trying your seemingly hard methods.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 04:20 AM
No, you can't detect collision if you CFrame part in other part. Joints aren't problem, simply:

part:BreakJoints()

Remember to add velocity and break joints for unanchored parts only, so it doesn't do unexpected things.
Report Abuse
DeathLicht is not online. DeathLicht
Joined: 06 Jun 2011
Total Posts: 340
05 Apr 2013 04:27 AM
try this script >>>>>>> NukeExplosion.script <<<< script is inside NukeExplosion

while wait(.1) do

for _,parts in ipairs(game.Workspace:GetChildren()) do
if parts.CFrame ~= nil and (parts.Position - script.Parent.Position).Magnitude <= script.Parent.Size then

parts:breakJoints()
parts.Velocity = Vector3.new(math.random(99)-50,math.random(99)-50,math.random(99)-50)

end
end

script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)

end

Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 04:28 AM
@Death. Epic, unbearable lag.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 05:47 AM
I did it! I used explosion for touch detection this time. It works perfectly, but expect lag when nuking a lot of objects.
==========
--Debounce variable
NukeInitiated = false
local NukeTrigger = script.Parent

script.Parent.Touched:connect(function()
if not NukeInitiated then
NukeInitiated = true

--User variables
local Size = 100
local SizeIncrement = 2 --High value will cause lag
local Speed = 100 --High value will cause lag

--Create explosion field
local ExplosionField = Instance.new("Part",script.Parent)
ExplosionField.Name = "ExplosionField"
ExplosionField.BrickColor = BrickColor.new("Bright yellow")
ExplosionField.Shape = "Ball"
ExplosionField.Material = "Plastic"
ExplosionField.Reflectance = 0
ExplosionField.Transparency = 0.5
ExplosionField.Position = script.Parent.Position
ExplosionField.Anchored = true
ExplosionField.Archivable = false
ExplosionField.CanCollide = false
ExplosionField.BottomSurface = "Smooth"
ExplosionField.TopSurface = "Smooth"

--Make the explosion expand
local DefaultCFrame = ExplosionField.CFrame
for Radius = 1,Size do
local Explosion = Instance.new("Explosion",script.Parent)
Explosion.Name = "Explosion"
Explosion.BlastPressure = 1
Explosion.BlastRadius = Radius
Explosion.Position = script.Parent.ExplosionField.Position
Explosion.Hit:connect(function(Hit)
Hit:BreakJoints()
Hit.Anchored = false
ExplosionField.Anchored = true
NukeTrigger.Anchored = true
Hit.Velocity = script.Parent.Explosion.Position + Hit.Position
end)
ExplosionField.Size = ExplosionField.Size + Vector3.new(SizeIncrement,SizeIncrement,SizeIncrement)
ExplosionField.CFrame = DefaultCFrame
wait(1 / (Speed * .02))
end

--Stop the explosion
wait(2)
Explosion:Destroy()
ExplosionField:Destroy()
NukeInitiated = false
end
end)
==========
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Apr 2013 06:50 AM
Well explosion has limited range, as far as I know.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 02:00 PM
How do I reset the rotation of a part to default? I'm creating a shockwave but it keeps falling over to the side.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
05 Apr 2013 02:25 PM
Oh, and you're right, explosion does have limited radius... That's sad, it was probably the only efficient method of detecting touches.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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