davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:20 PM |
Well i have this script, it should run fine but Roblox likes to be crazy.
sp = script.Parent spp = script.Parent.Parent while spp do wait() if script.Parent.Parent.Name == "PlayerGui" then --No need for the rest of the script
Even though in the script is shown that the loop only should run when script.Parent.Parent exists, it still errors:
Workspace.PlayerComputer.Backup.ComputerGui.PlayerChecker:5: attempt to index field 'Parent' (a nil value) |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 01:22 PM |
try doing
sp = script.Parent spp = script.Parent.Parent
while sp and spp do wait() if sp ~= nil and spp ~= nil then if script.Parent.Parent.Name == "PlayerGui" then |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:24 PM |
| Thanks. It fixed the problem. |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:27 PM |
| Oh wait. It still didn't fix it. |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 01:29 PM |
| Thats weird...Is there any other information you can provide? Maybe put some prints in there and see what they say? |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:35 PM |
| Well, the script is in a ScreenGui. From start of the game the Gui is inside a model, when a player sits down to a chair the gui gets moved into the player's PlayerGui. Every (0) seconds Gui's copy gets sent to a model inside the start model. When player jumps off the chair HIS gui gets deleted, but the copied one moves to position like it was in start (kind of like a circulation). Prints are not needed, because that is the only line which errors. |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 01:37 PM |
| So basically youre trying to clone the GUI from a model and move it to the PlayerGui then vise versa when they jump off? |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:42 PM |
| Pretty much yeah. I can give you a model of it so you can understand it better if you need. |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 01:46 PM |
I havent done this in a while
put the GUI in Lighting:
put this in the seat:
gui = game.Lighting.GUI
script.Parent.ChildAdded:connect(function(p) --I think thats how it works for seats local player = game.Players:findFirstChild(p.Name) --Or is it p.Parent.Name...? gui:clone().Parent = player.PlayerGui end)
script.Parent.ChildRemoved:connect(function(pp) local player = game.Players:findFirstChild(pp.Name) if player.PlayerGui:findFirstChild("GUI") then player.PlayerGui.GUI:Destroy() end end) |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:48 PM |
| Well, the Gui saves things, so no worries about that. But still the spam of errors, or should i leave it like that? |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:49 PM |
Btw, seat script:
while true do wait() weld = script.Parent:findFirstChild("SeatWeld") if weld then player = game.Players:GetPlayerFromCharacter(script.Parent.SeatWeld.Part1.Parent) Gui = script.Parent.Parent.Parent.Parent:findFirstChild("ComputerGui") GuiCheck = player.PlayerGui:findFirstChild("ComputerGui") if Gui and GuiCheck == nil then Gui.Parent = player.PlayerGui script.Parent.Parent.Parent.Parent.Name = player.Name.."Computer" elseif Gui == nil then script.Parent.Parent.Parent.Parent.Name = player.Name.."Computer" end elseif weld == nil then script.Parent.Parent.Parent.Parent.Name = "Computer" end end
|
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 01:52 PM |
| if it works you can just put a pcall on the line with errors? Im still not fully understanding your script. I never scripted using welds. |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
| |
|
|
| 26 Apr 2015 01:56 PM |
Protected call, if theres an error, it will skip that line of code.
ex:
pcall(function() player.Name = "umg" end)
If you put that in an empty script it wont throw an error. |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 01:59 PM |
| pcall(function() while sp and spp do end end) --Like this? |
|
|
| Report Abuse |
|
|
| |
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 26 Apr 2015 02:09 PM |
| It still printed the errors. |
|
|
| Report Abuse |
|
|