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: Why does this work in studio but not in-game

Previous Thread :: Next Thread 
TheOsiris is not online. TheOsiris
Joined: 30 May 2010
Total Posts: 4534
30 Dec 2015 10:00 PM
Hi, I need help. I created a billboard gui that's attached to your head, but it only works in Studio. I am unsure why it does.

groupid = 1181615
game.Players.PlayerAdded:connect(onPlayerRespawned)
function onPlayerRespawned(newPlayer)
wait(1)
if newPlayer:IsInGroup(groupid) then
gui=Instance.new("BillboardGui")
gui.Parent=newPlayer.Character.Head
gui.Adornee=newPlayer.Character.Head
gui.Size=UDim2.new(4,0,2,0)
gui.StudsOffset=Vector3.new(0,3,0)
texta=Instance.new("TextBox")
texta.Size=UDim2.new(1,0,1,0)
texta.BackgroundTransparency = 1
texta.TextColor3 = Color3.new(0,0.5,1)
texta.Font = "SourceSansLight"
texta.FontSize = "Size24"
texta.Text = (game.Players.LocalPlayer.Name .. " || " .. newPlayer:GetRoleInGroup(groupid) .. "")
texta.Parent=gui
w = game.Lighting.WepsGroup:GetChildren()
for i = 1,#w do
w[i]:Clone().Parent = newPlayer.Backpack
end
end
end

function onPlayerEntered(newPlayer)
newPlayer.Changed:connect(function (property)
if (property == "Character") then
onPlayerRespawned(newPlayer)
end
end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
Report Abuse
FlyNormal is not online. FlyNormal
Joined: 30 Sep 2015
Total Posts: 344
30 Dec 2015 10:05 PM
Any error(s)? The possible error is that you have not waited for the head to load.

Use this way for waiting, it's better:

local character = player.CharacterAdded:wait() or player.Character
local head = character:WaitForChild("Torso")
Report Abuse
TheOsiris is not online. TheOsiris
Joined: 30 May 2010
Total Posts: 4534
30 Dec 2015 10:12 PM
Fly, Workspace.Script:4: attempt to index global 'player' (a nil value)
Report Abuse
13Jayson is not online. 13Jayson
Joined: 05 Jun 2012
Total Posts: 1682
30 Dec 2015 10:19 PM
Idk, I had the same probleme of something else and it was because on studio u load faster than the script, so im pretty sure in the game... the script is faster...


Not 100% sure though, plus that was almost year ago so... You should think about it if you didn't .o.



Meeooow!!!!!!13!!!
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
30 Dec 2015 10:22 PM
"Not 100% sure though, plus that was almost year ago"




You got the point across, but let me make it a little more specific.

In Studio, everything is already loaded, you don't need to wait for anything. In a game, things take time to stream and load and the like, and your character can take a few seconds to actually spawn.
Report Abuse
13Jayson is not online. 13Jayson
Joined: 05 Jun 2012
Total Posts: 1682
30 Dec 2015 10:25 PM
@Jar

Heh, I am bad at explaining, plus my native language isn't english so... It's a bit harder for me xd



Meeooow!!!!!!13!!!
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