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 » Scripting Helpers
Home Search
 

Re: Anyone know why this breaks when you reset?

Previous Thread :: Next Thread 
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:38 AM
--Only works on the first spawn

repeat wait()
Z=game.Players.LocalPlayer.Character
A=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area1"):FindFirstChild("Player").Value
B=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area2"):FindFirstChild("Player").Value
C=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area3"):FindFirstChild("Player").Value
D=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area4"):FindFirstChild("Player").Value
E=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area5"):FindFirstChild("Player").Value
F=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area6"):FindFirstChild("Player").Value
G=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area7"):FindFirstChild("Player").Value
H=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area8"):FindFirstChild("Player").Value
I=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area9"):FindFirstChild("Player").Value
until Z and A and B and C and D and E and F and G and H and I


script.Parent.MouseButton1Down:connect(function()
if A==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -398)
elseif
B==Z.Name then
Z.Torso.CFrame=CFrame.new(24, 47.08, -453)
elseif
C==Z.Name then
Z.Torso.CFrame=CFrame.new(15, 47.08, -333)
elseif
D==Z.Name then
Z.Torso.CFrame=CFrame.new(80, 47.08, -388)
elseif
E==Z.Name then
Z.Torso.CFrame=CFrame.new(-152, 47.08, -398)
elseif
F==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -333)
elseif
G==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -510)
elseif
H==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -557)
elseif I==Z.Name then
Z.Torso.CFrame=CFrame.new(25, 47.08, -565)
end
end)
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
17 May 2014 09:40 AM
It breaks because it is local script, and it is inside Player's folder... I am not really sure how to fix this though...
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:40 AM
It's in a textbutton.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:42 AM
Replace the first line of the script with
repeat wait() until Game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
17 May 2014 09:43 AM
Bebee I think this is LocalScript...
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:44 AM
@bebe
that gives the until Z and A and B and C and D line an error
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:45 AM
It will error if it defines LocalPlayer and there is no LocalPlayer because the value of LocalPlayer is nil. You have to yield until LocalPlayer exists for the script to define LocalPlayer otherwise you will get the error "attempt to index 'Character' from a nil value 'LocalPlayer" or something like that.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:45 AM
Remove that line entirely because the DataModel will most likely be loaded before those exists.
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:52 AM
i literally have no idea what line you're telling me to remove
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:54 AM
until Z and A and B and c and D and E

Etc.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:55 AM
Anyways, when you die. Does the value of ABCDEFGHI change?
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:56 AM
it broke the script
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:57 AM
no, it doesn't change.
it's the gui that is broken
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 09:57 AM
Post the entire script.
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 09:58 AM
repeat wait() until Game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character
Z=game.Players.LocalPlayer.Character
A=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area1"):FindFirstChild("Player").Value
B=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area2"):FindFirstChild("Player").Value
C=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area3"):FindFirstChild("Player").Value
D=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area4"):FindFirstChild("Player").Value
E=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area5"):FindFirstChild("Player").Value
F=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area6"):FindFirstChild("Player").Value
G=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area7"):FindFirstChild("Player").Value
H=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area8"):FindFirstChild("Player").Value
I=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area9"):FindFirstChild("Player").Value


script.Parent.MouseButton1Down:connect(function()
if A==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -398)
elseif
B==Z.Name then
Z.Torso.CFrame=CFrame.new(24, 47.08, -453)
elseif
C==Z.Name then
Z.Torso.CFrame=CFrame.new(15, 47.08, -333)
elseif
D==Z.Name then
Z.Torso.CFrame=CFrame.new(80, 47.08, -388)
elseif
E==Z.Name then
Z.Torso.CFrame=CFrame.new(-152, 47.08, -398)
elseif
F==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -333)
elseif
G==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -510)
elseif
H==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -557)
elseif I==Z.Name then
Z.Torso.CFrame=CFrame.new(25, 47.08, -565)
end
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 10:02 AM
You can always change all the FindFirstChild's into WaitForChild

I can't see how that previous one would work considering if one part is nil, the method will fail because you can index from nil unless nil is a table.



What's the error, anyways?
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 10:03 AM
No errors.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 May 2014 10:06 AM

zzozoz = game.Players.LocalPlayer
zzozoz.CharacterAdded:connect(function(Z)
A=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area1"):FindFirstChild("Player").Value
B=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area2"):FindFirstChild("Player").Value
C=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area3"):FindFirstChild("Player").Value
D=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area4"):FindFirstChild("Player").Value
E=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area5"):FindFirstChild("Player").Value
F=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area6"):FindFirstChild("Player").Value
G=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area7"):FindFirstChild("Player").Value
H=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area8"):FindFirstChild("Player").Value
I=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area9"):FindFirstChild("Player").Value
until Z and A and B and C and D and E and F and G and H and I


script.Parent.MouseButton1Down:connect(function()
if A==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -398)
elseif
B==Z.Name then
Z.Torso.CFrame=CFrame.new(24, 47.08, -453)
elseif
C==Z.Name then
Z.Torso.CFrame=CFrame.new(15, 47.08, -333)
elseif
D==Z.Name then
Z.Torso.CFrame=CFrame.new(80, 47.08, -388)
elseif
E==Z.Name then
Z.Torso.CFrame=CFrame.new(-152, 47.08, -398)
elseif
F==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -333)
elseif
G==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -510)
elseif
H==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -557)
elseif I==Z.Name then
Z.Torso.CFrame=CFrame.new(25, 47.08, -565)
end
end)
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 10:10 AM
-- What happens now?
repeat wait() until Game.Players.LocalPlayer
Z=game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()
A=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area1"):FindFirstChild("Player")
B=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area2"):FindFirstChild("Player")
C=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area3"):FindFirstChild("Player")
D=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area4"):FindFirstChild("Player")
E=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area5"):FindFirstChild("Player")
F=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area6"):FindFirstChild("Player")
G=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area7"):FindFirstChild("Player")
H=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area8"):FindFirstChild("Player")
I=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area9"):FindFirstChild("Player")


script.Parent.MouseButton1Down:connect(function()
if A.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -398)
elseif
B.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(24, 47.08, -453)
elseif
C.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(15, 47.08, -333)
elseif
D.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(80, 47.08, -388)
elseif
E.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(-152, 47.08, -398)
elseif
F.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -333)
elseif
G.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -510)
elseif
H.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -557)
elseif I.Value==Z.Name then
Z.Torso.CFrame=CFrame.new(25, 47.08, -565)
end
end)
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 10:11 AM
sensei
red lines under until Z and A and B etc

Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 May 2014 10:11 AM
zzozoz = game.Players.LocalPlayer
zzozoz.CharacterAdded:connect(function(Z)
A=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area1"):FindFirstChild("Player").Value
B=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area2"):FindFirstChild("Player").Value
C=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area3"):FindFirstChild("Player").Value
D=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area4"):FindFirstChild("Player").Value
E=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area5"):FindFirstChild("Player").Value
F=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area6"):FindFirstChild("Player").Value
G=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area7"):FindFirstChild("Player").Value
H=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area8"):FindFirstChild("Player").Value
I=Workspace:FindFirstChild("BuildingAreas"):FindFirstChild("Area9"):FindFirstChild("Player").Value
repeat wait() until Z and A and B and C and D and E and F and G and H and I


script.Parent.MouseButton1Down:connect(function()
if A==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -398)
elseif
B==Z.Name then
Z.Torso.CFrame=CFrame.new(24, 47.08, -453)
elseif
C==Z.Name then
Z.Torso.CFrame=CFrame.new(15, 47.08, -333)
elseif
D==Z.Name then
Z.Torso.CFrame=CFrame.new(80, 47.08, -388)
elseif
E==Z.Name then
Z.Torso.CFrame=CFrame.new(-152, 47.08, -398)
elseif
F==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -333)
elseif
G==Z.Name then
Z.Torso.CFrame=CFrame.new(-40, 47.08, -510)
elseif
H==Z.Name then
Z.Torso.CFrame=CFrame.new(-97, 47.08, -557)
elseif I==Z.Name then
Z.Torso.CFrame=CFrame.new(25, 47.08, -565)
end
end)
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 10:13 AM
@Sensei, even if one of those things didn't exist... the error would be "attempt to index a nil value"

Even if that was bypassed, it would yield forever because ABCDEFGHIZ will never be updated.
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 10:14 AM
sensei's didn't work
no output
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 May 2014 10:15 AM
Would help to know what part isn't working...

Is it not teleporting?
Report Abuse
Phyclops is not online. Phyclops
Joined: 27 Sep 2012
Total Posts: 5895
17 May 2014 10:16 AM
yeah it doesn't teleport
but yours

the "-- What happens now?" post you made

it teleports me
but when i reset
it breaks again
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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