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: function ain't workin?

Previous Thread :: Next Thread 
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
25 Feb 2015 08:35 PM
local function ff(plr)
local ff = Instance.new("ForceField",plr.Character)
end

says plr is a nil value

but...

elseif m:lower():sub(0,3) == "ff/" then
local plr = game.Players:FindFirstChild(m:lower():sub(4))
ff(plr)
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:36 PM
do this: print(m:lower():sub(4))

You'll see what's wrong
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
25 Feb 2015 08:38 PM
i don't see what's wrong?

20:37:07.097 - ServerScriptService.AdminScript:28: attempt to index local 'plr' (a nil value)
20:37:07.098 - Stack Begin
20:37:07.099 - Script 'ServerScriptService.AdminScript', Line 28 - upvalue ff
20:37:07.099 - Script 'ServerScriptService.AdminScript', Line 83
20:37:07.100 - Stack End
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:39 PM
Put the print above the
local plr = ...

(I'm pretty sure it should be :sub(3))
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:40 PM
Also. You might want to do this to avoid errors

if plr ~= nil then
ff(plr)
end
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
25 Feb 2015 08:41 PM
To check if something is there, you don't have to do ~= nil. If you just put if plr then, that works too.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
25 Feb 2015 08:43 PM
Now my unff command isn't working...

local function unff(plr)
for _,v in next, plr.Character do
if v:IsA("ForceField") then
v:Destroy()
end
end
end
Report Abuse
ChoongJae is not online. ChoongJae
Joined: 10 Oct 2009
Total Posts: 670
25 Feb 2015 08:51 PM
for _,v in next, plr.Character do

don't you mean

for _,v in next, plr.Character:GetChildren() do
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:55 PM
for _,v in next, plr.Character do

This is actually new to me. what is the purpose of 'next' here?
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:56 PM
http://lua-users.org/wiki/ForTutorial

Oh huh, that's super interesting
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
25 Feb 2015 08:56 PM
character = player.Character or player.CharacterAdded:wait()

^
Suggestion. Modify to needs.
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 08:57 PM
To understand what exactly DiamondBladee is doing check this article:
http://lua-users.org/wiki/TernaryOperator

It's called a ternary, bascially it's a compressed if satement
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
26 Feb 2015 08:09 AM
I know what that is lol, but thanks anyways. And yeah, I saw my careless mistake.
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