I know that this is for when a player enters; but i cant seem to get it to automatically update for my RPG. Basically the GUi above the players head will show his level, and when he levels up the gui should update, but idk how to put this into the code without it messing up the parameters:
game.Players.PlayerAdded:connect(onPlayerRespawned) function onPlayerRespawned(newPlayer) wait(1) gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,3,0) gui.StudsOffset=Vector3.new(0,2,0) local text1=Instance.new("TextLabel") text1.Text = ("Level:"..newPlayer.leaderstats.Lvl.Value) text1.FontSize = "Size14" text1.TextColor3 = Color3.new(170, 0, 0) text1.TextStrokeColor3 = Color3.new(0, 0, 0) text1.TextStrokeTransparency = 0 text1.Size=UDim2.new(1,0,1,0) text1.Position=UDim2.new(0,0,0,0) text1.BackgroundTransparency = 1 text1.Parent=gui end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.PlayerAdded:connect(onPlayerEntered)
thanks ~ bubs
You seem to have a 'non-perfect' event ;p
The '.Changed' should only be used when there aren't any events for that case. In this case, we got an event called 'CharacterAdded'
Let's change the code:
newPlayer.Changed(...) -- Delete that. :)
Now we need to make it actually connect the event, so we got the final code of:
game.Players.PlayerAdded:connect(onPlayerRespawned) function onPlayerRespawned(newPlayer) wait(1) gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,3,0) gui.StudsOffset=Vector3.new(0,2,0) local text1=Instance.new("TextLabel") text1.Text = ("Level:"..newPlayer.leaderstats.Lvl.Value) text1.FontSize = "Size14" text1.TextColor3 = Color3.new(170, 0, 0) text1.TextStrokeColor3 = Color3.new(0, 0, 0) text1.TextStrokeTransparency = 0 text1.Size=UDim2.new(1,0,1,0) text1.Position=UDim2.new(0,0,0,0) text1.BackgroundTransparency = 1 text1.Parent=gui end function onPlayerEntered(newPlayer) --[[newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end)]]-- newPlayer.CharacterAdded:connect(function(char) onPlayerRespawned(newPlayer) end) end game.Players.PlayerAdded:connect(onPlayerEntered)
But now we face a dillema: WE WANT IT TO AUTO UPDATE!
For this, make a new LocalScript in Backpack. Now change this to the code:
function onPlayerUpdate() wait(1) if (game:service('Players').LocalPlayer.Character:FindFirstChild('Head')~=nil) then if (game:service('Players').LocalPlayer.Character.Head:FindFirstChild("BillboardGui")==nil then gui=Instance.new("BillboardGui") gui.Parent=game:service('Players').LocalPlayer.Character.Head gui.Adornee=game:service('Players').LocalPlayer.Character.Head gui.Size=UDim2.new(3,0,3,0) gui.StudsOffset=Vector3.new(0,2,0) local text1=Instance.new("TextLabel") text1.Text = ("Level:"..game:service('Players').LocalPlayer.leaderstats.Lvl.Value) text1.FontSize = "Size14" text1.TextColor3 = Color3.new(170, 0, 0) text1.TextStrokeColor3 = Color3.new(0, 0, 0) text1.TextStrokeTransparency = 0 text1.Size=UDim2.new(1,0,1,0) text1.Position=UDim2.new(0,0,0,0) text1.BackgroundTransparency = 1 text1.Parent=gui else game:service('Players').LocalPlayer.Character.Head.BillboardGui.TextLabel.Text= ("Level:"..game:service('Players').LocalPlayer.leaderstats.Lvl.Value) end end end while true do onPlayerUpdate() wait(.1) end
Also make sure you make the LocalScript...
Thanks! ~marcoantoniosantos3