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: why does this delete the player howtofix

Previous Thread :: Next Thread 
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 03:48 PM
local removeffs=player.Character:GetChildren()
for i=1, #removeffs do
if (removeffs[i].Name == ("SpecialForceField") or ("ForceField")) then
removeffs[i]:Destroy()
end


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 03:49 PM
the character I mean.


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
09 Apr 2017 03:53 PM
Because this:

if (removeffs[i].Name == ("SpecialForceField") or ("ForceField")) then


Is treated like this:

if (removeffs[i].Name == "SpecialForceField") or "ForceField" then
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 03:53 PM
can you post the whole script since I can't test it due to missing stuff


r+://718058112r+://718058837
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 03:54 PM
but as chimm said it should be:

(removeffs[i].Name == (("SpecialForceField") or ("ForceField")))


r+://718058112r+://718058837
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
09 Apr 2017 03:55 PM
I didn't say that.

Adding more parenthesis isn't going to fix it.
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 03:56 PM
The extra parenthesise should treat it as:

removeeffs[i].Name == "SpecialForceField" or removeeffs[i].Name == ForceField


And I meant you mentioned that the line was wrong


r+://718058112r+://718058837
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 03:59 PM
thanks guys, got it to work
I just didn't know how to present that part of the script lol


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
09 Apr 2017 04:00 PM
or is an operator on its own, it is not connected to the == operator in any way.
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:01 PM
oh I see


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
09 Apr 2017 04:04 PM
(removeffs[i].Name == ("SpecialForceField") or ("ForceField"))

will always evaluate to true because the string "ForceField" is considered "truthy" or non-nil.

So it's like saying

if (removeffs[i].Name == "SpecialForceField" or true) then
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 04:06 PM
If that's true why does:
local allow = (player.Name == ("Player12" or "Player10"))
if not allow then
etc.

work for any name in the list


r+://718058112r+://718058837
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
09 Apr 2017 04:11 PM
local allow = (player.Name == "Player12" or player.Name == "Player10")
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
09 Apr 2017 04:12 PM
@iSent

The script first looks at "Player12" or "Player10" and determines that it's truthy because they're both not nil. After, it checks to see whether player.Name is truthy. Because the player name is always truthy as well, that line is basically setting the allow variable to true == true which is true. Therefore allow will always be true.
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:12 PM
function onClicked()
if script.Parent.Text =="OFF" then

local removeffs=player.Character:GetChildren()
for i=1, #removeffs do
if removeffs[i].Name == "SpecialForceField" or removeffs[i].Name == "ForceField" then
removeffs[i]:Destroy()

local clone = game.ReplicatedStorage.RocketLauncher:Clone()
clone.Parent=game.Players.LocalPlayer.Backpack
script.Parent.Text="PVP"

end
end


having one more issue with the script, this gives the player 3 rocket launchers when they're only supposed to get one


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 04:14 PM
nvm ignore me

I thought what I had worked but it didn't


r+://718058112r+://718058837
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
09 Apr 2017 04:14 PM
That's because the part that gives the tool to the player is inside the for loop, so it may repeat a couple times depending on how many forcefields are found inside the character.
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 04:14 PM
If the first value in my list is the name of the user then it works, but only looks at the first


r+://718058112r+://718058837
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:15 PM
oh I see, there are # ########### and @s it did work tho Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:15 PM
@is it worked tho


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:16 PM
nvm I just used the longer version but it works either way


Are you today's date.... Cause you're 10/ 10 TX69
Report Abuse
iSentinels is not online. iSentinels
Joined: 03 Jan 2009
Total Posts: 28706
09 Apr 2017 04:17 PM
the shorter version won't work

the longer version does


r+://718058112r+://718058837
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
09 Apr 2017 04:23 PM
...

for i,v in next, game.Players:GetPlayers() do
local ff = v.Character:FindFirstChildOfClass('ForceField')
if ff then ff:Destroy() end
end


Report Abuse
Golden_Flame is not online. Golden_Flame
Joined: 13 Sep 2011
Total Posts: 15431
09 Apr 2017 04:31 PM
heh is that new cuz It would be a lot cleaner


Are you today's date.... Cause you're 10/ 10 TX69
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