|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|