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: Beginner help please and thanks

Previous Thread :: Next Thread 
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:15 PM
How do I make a part change a property (of my choice) of any part that is touching the part.

So basically what do I need to do/learn to make for example,
make a part that destroys anything that touches it. Even if it's being touched by another part already.

I know how to make a part destroy other parts using this

===========================================
function DIEPART(hit)
hit:Destroy()
end

script.Parent.Touched:connect(DIEPART)
============================================

but the problem is using this script the part will not destroy other parts that are already touching it once I load up the game.

Hope somebody can help

thanks in regards
Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:16 PM
I'm thinking i might need to use an "if" statement to do this but i'm not sure
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 Sep 2016 02:16 PM
Because if the part is already touching, it won't fire the event. You need to move the parts again for the event to fire.


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 Sep 2016 02:17 PM
However you could always see what parts are touching by using a handy function:

part:GetTouchingParts()

this will return a table of all the parts that are currently touching the part


Report Abuse
real_words is not online. real_words
Joined: 25 Feb 2016
Total Posts: 2184
02 Sep 2016 02:20 PM
local parts = {}
local ins = table.insert
local part = workspace.Part

ins(parts,part:GetTouchingParts())


Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:31 PM
I'm a noob and i tried this


local parts = {"Yo","Part"}
local ins = table.insert
local part = workspace.Part

ins(parts,part:GetTouchingPartsDestroy())


but doesn't work and can't figure it out but ill keep trying.
Report Abuse
real_words is not online. real_words
Joined: 25 Feb 2016
Total Posts: 2184
02 Sep 2016 02:36 PM
local parts = {}
local ins = table.insert
local part = workspace.Part
local touched = false
part.Touched:connect(function(hit)
touched = true
end)
part.TouchEnded:connect(function(hit)
touched = false
end)
ins(parts,part:GetTouchingPartsDestroy())

repeat wait() until not touched

for _,v in ipairs(parts()) do
if game.Workspace:FindFirstChild(v) then
local P = game.Workspace[v]
P:Destroy()
end
end


Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:39 PM
Thanks for the help but that is too complicated for my knowledge at the moment is there a simpler way to do it or can you at least explain it so i understand because I just tried it

local parts = {}
local ins = table.insert
local part = workspace.Part
local touched = false
part.Touched:connect(function(hit)
touched = true
end)
part.TouchEnded:connect(function(hit)
touched = false
end)
ins(parts,part:GetTouchingPartsDestroy())

repeat wait() until not touched

for _,v in ipairs(parts()) do
if game.Workspace:FindFirstChild(v) then
local P = game.Workspace[v]
P:Destroy()
end
end

but it doesn't work and i don't know why not.
Report Abuse
real_words is not online. real_words
Joined: 25 Feb 2016
Total Posts: 2184
02 Sep 2016 02:42 PM
local parts = {} -- table of parts
local ins = table.insert -- table.insert
local part = workspace.Part -- the part that gets hit
local touched = false -- touched local
part.Touched:connect(function(hit) -- touch started
touched = true -- sets touched as true
end)
ins(parts,part:GetTouchingPartsDestroy()) -- inserts every touched parts into the parts table
part.TouchEnded:connect(function(hit) -- touch ended, sets touched as false
touched = false
end)
repeat wait() until not touched -- waits until finished touching

for _,v in ipairs(parts()) do -- scans parts
if game.Workspace:FindFirstChild(v) then -- checks if v is a member of workspace
local P = game.Workspace[v]
P:Destroy() -- destroys it
end
end


Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:52 PM
local parts = {"Part","Yo"} -- table of parts
local ins = table.insert -- table.insert
local part = workspace.Part -- the part that gets hit
local touched = false -- touched local
part.Touched:connect(function(hit) -- touch started I don't know what to do here???
touched = true -- sets touched as true
end)
ins(parts,part:GetTouchingPartsDestroy()) -- inserts every touched parts into the parts table
part.TouchEnded:connect(function(hit) -- touch ended, sets touched as false
touched = false
end)
repeat wait() until not touched -- waits until finished touching

for _,v in ipairs(parts()) do -- scans parts
if game.Workspace:FindFirstChild("Part","Yo") then -- checks if v is a member of workspace
local P = game.Workspace["Part","Yo"]
P:Destroy() -- destroys it
end
end

Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 02:53 PM
not working
Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 03:03 PM
Also noting i'm not using filtering enabled
Report Abuse
Tobycon is not online. Tobycon
Joined: 22 May 2013
Total Posts: 1527
02 Sep 2016 03:52 PM
bup
Report Abuse
boatbomber is not online. boatbomber
Joined: 26 Oct 2012
Total Posts: 386
02 Sep 2016 03:57 PM
lmao this started out super simple but then these guys blew it out of proportion
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