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: How can I Remove EVERY ForceField from player?

Previous Thread :: Next Thread 
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Aug 2011 03:21 AM
[ Content Deleted ]
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Aug 2011 03:23 AM
[ Content Deleted ]
Report Abuse
superior is not online. superior
Joined: 13 Apr 2008
Total Posts: 1662
21 Aug 2011 03:29 AM
One more post before I go to bed. xD

plyr = player
local a = player:children()
for x = 1, #plyr do
if plyr[x].ClassName == "forcefield" then
plyr[x]:Remove()
end
end

Something like this. If there are more than one forcefield, you have to use the "for" statement. :findFirstChild("") finds the first child of the object.
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Aug 2011 03:30 AM
[ Content Deleted ]
Report Abuse
superior is not online. superior
Joined: 13 Apr 2008
Total Posts: 1662
21 Aug 2011 03:42 AM
That line that you mentioned. Going to bed, I'll help in the morning.
Report Abuse
gombob is not online. gombob
Joined: 01 May 2008
Total Posts: 5215
21 Aug 2011 04:54 AM
local ButtonCon = script.Parent
local Frame = script.Parent.Parent
local Text = script.Parent.Parent.TextLabel
local AFKbutton = script.Parent.Parent.Parent.TextButton
local Torso = script.Parent.Parent.Parent.Parent.Parent.Character.Torso


function onClick()
for i=1, 10 do
ButtonCon.BackgroundTransparency = i/10
ButtonCon.TextTransparency = i/10
wait()
end
for i=1,10 do
Text.TextTransparency = i/10
wait()
end
for i=1,10 do
Frame.BackgroundTransparency = i/10
wait()
end

AFKbutton.Visible = true
script.Parent.Parent.Runner.Disabled = true
Frame.Visible = false
while(Torso.Parent:FindFirstChild("ForceField", true)) do
Torso.Parent:FindFirstChild("ForceField", true).Parent = nil
end
Torso.Parent.Humanoid.WalkSpeed = 16
end

--[[
It will only remove ForceFields with the name "ForceField"
e.g. If a ForceField has the name "FField", it won't be removed

I tested it and it worked :p
]]
Report Abuse
0supadude0 is not online. 0supadude0
Joined: 11 Aug 2010
Total Posts: 649
21 Aug 2011 05:05 AM
local ButtonCon = script.Parent
local Frame = script.Parent.Parent
local Text = script.Parent.Parent.TextLabel
local AFKbutton = script.Parent.Parent.Parent.TextButton
local Torso = script.Parent.Parent.Parent.Parent.Parent.Character.Torso


function onClick()
for i=1, 10 do
ButtonCon.BackgroundTransparency = i/10
ButtonCon.TextTransparency = i/10
wait()
end
for i=1,10 do
Text.TextTransparency = i/10
wait()
end
for i=1,10 do
Frame.BackgroundTransparency = i/10
wait()
end

AFKbutton.Visible = true
script.Parent.Parent.Runner.Disabled = true
Frame.Visible = false
c = Torso.Parent:GetChildren()
for i = 1, #c do
if c[i].className == "ForceField" then
c[i]:remove()
end
end
Torso.Parent.Humanoid.WalkSpeed = 16
end

--[[ That will remove every forcefield no matter what it's called. Unless I made a spelling mistake ]]
Report Abuse
gombob is not online. gombob
Joined: 01 May 2008
Total Posts: 5215
21 Aug 2011 05:10 AM
But it won't remove ForceFields inside the Head or Torso because it isn't recursive...

This one will remove all ForceFields regardless which name they have:

local ButtonCon = script.Parent
local Frame = script.Parent.Parent
local Text = script.Parent.Parent.TextLabel
local AFKbutton = script.Parent.Parent.Parent.TextButton
local Torso = script.Parent.Parent.Parent.Parent.Parent.Character.Torso


local function DelFF(par)
local kids = par:children()
for i=1, #kids do
if kids[i]:IsA("ForceField") then
kids[i].Parent = nil
else
DelFF(kids[i])
end
end
end

function onClick()
for i=1, 10 do
ButtonCon.BackgroundTransparency = i/10
ButtonCon.TextTransparency = i/10
wait()
end
for i=1,10 do
Text.TextTransparency = i/10
wait()
end
for i=1,10 do
Frame.BackgroundTransparency = i/10
wait()
end

AFKbutton.Visible = true
script.Parent.Parent.Runner.Disabled = true
Frame.Visible = false
DelFF(Torso.Parent)
Torso.Parent.Humanoid.WalkSpeed = 16
end


Report Abuse
UttermostExedra is not online. UttermostExedra
Joined: 28 Dec 2009
Total Posts: 2483
21 Aug 2011 05:22 AM
Unneccecary functions aren't needed. What you need here is a simple for loop.


for INDEX,VALUE in pairs(INSTANCE:GetChildren()) do
if VALUE:IsA("ForceField") then
VALUE:remove()
end
end
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Aug 2011 06:15 AM
[ Content Deleted ]
Report Abuse
gombob is not online. gombob
Joined: 01 May 2008
Total Posts: 5215
21 Aug 2011 07:32 AM
@UtterMost: That function was needed because it keeps calling itself until all the ForceFields are deleted. It's the only way to delete all possible ForceFields
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