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
 

Why won't this script work?

Previous Thread :: Next Thread 
California_Officer is not online. California_Officer
Joined: 20 Feb 2017
Total Posts: 5
09 Oct 2017 02:34 PM
Relatively new to scripting. My basic script won't work. Doesn't throw up an error or anything - just doesn't do anything whatsoever.

call = game.Workspace["911Calls"].Reports:FindFirstChild(script.Parent.IDV.Value)

function Take()
call.Taken.Value = true
call.Taker.Value = script.Parent.Parent.Parent.Parent.Parent.Parent.Name
g = script.Parent.CallerG:Clone()
g.Parent = script.Parent.Parent.Parent.Parent.Parent
g.Adornee = game.Workspace:FindFirstChild(script.Parent.CallerV.Value).Head
g.Enabled = true

end
function Clear()
call.Cleared.Value = true
g:Remove()
end



while true do
if call.Taken.Value == true then
script.Parent.TAKE.Visible = false
script.Parent.RO.Text = call.Taker.Value
end
end
while true do
if call.Cleared.Value == true then
script.Parent:Remove()
end
end

script.Parent.TAKE.MouseButton1Click:connect(Take)
script.Parent.CLEAR.MouseButton1Click:connect(Clear)
Report Abuse
RBX_Lua is online. RBX_Lua
Joined: 23 Nov 2010
Total Posts: 627
09 Oct 2017 02:39 PM
while true do
if call.Taken.Value == true then
script.Parent.TAKE.Visible = false
script.Parent.RO.Text = call.Taker.Value
end
end
while true do
if call.Cleared.Value == true then
script.Parent:Remove()
end
end

Both of these will cause the server to crash because they are infinite loops. Also only one of them is ever going to run because obviously nothing runs under an infinite loop. You need to use multiple threads for these loops.

Add a wait() to both loops OUTSIDE of the if statement.


Report Abuse
RBX_Lua is online. RBX_Lua
Joined: 23 Nov 2010
Total Posts: 627
09 Oct 2017 02:43 PM
I should clarify that infinite loops will not cause the server to crash, but an infinite loop without a yield will.

Also you can put both if statements in the same loop. No need for two.


Report Abuse
California_Officer is not online. California_Officer
Joined: 20 Feb 2017
Total Posts: 5
11 Oct 2017 12:30 AM
Something like

while true do
wait(1)
if call.Taken.Value == true then
script.Parent.TAKE.Visible = false
script.Parent.RO.Text = call.Taker.Value
end
if call.Cleared.Value == true then
script.Parent:Remove()
end
end

Now I'm just getting an error:
Players.California_Officer.PlayerGui.911Recieve.Calls.ScrollingFrame.Template.Script:21: attempt to index global 'call' (a nil value)

Even though the object "call" is pointing to exists.
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