Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my number script not working properly?

Whenever I playtest the game with 2 players, only their number gets shown, but not anyone else's.

For example: 2 players are in the game, they both have BillboardGuis on top of them. Both of those players can see "Your number is: THIS NUMBER" on their character, but when they look at each other's billboards, it just says "Your number is: LOADING...".

Here's the image link to explain it even further: http://pasteboard.co/nmpCqo9GrRD4.png

Here are the scripts I used:

The 1st script:

local billboard = script.BillboardGui

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
			local NumText = billboard:Clone()
			NumText.Parent = char.Head
			NumText.TextLabel.Text = "Your number is: LOADING..."
	end)
end)

The 2nd script:

local billboardamount = game.Players.LocalPlayer.Character.Head:WaitForChild("BillboardGui").TextLabel

local RandNum = Instance.new("NumberValue", game.Players.LocalPlayer)
RandNum.Value = math.random

while wait(0.1) do
	billboardamount.Text = "Your number is: "..
end

Can anyone please help me solve this problem?

1 answer

✓ Accepted answer

I think issue is that second script is in localscript so it will only show to player, what you should do is you can make remote event and fire it, then put script in serverscriptstorage and onserverevent change text, like this.

LocalScript

local billboardamount = game.Players.LocalPlayer.Character.Head:WaitForChild("BillboardGui").TextLabel

local RandNum = Instance.new("NumberValue", game.Players.LocalPlayer)
RandNum.Value = math.random

while wait(1) do
    game.ReplicatedStorage.RemoteEvent:FireServer(RandNum)
end

ServerScript

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,randnum)
	local bgui = player.Character.Head:WaitForChild("BillboardGui")
	bgui.Text = "Your number is: "..randnum
end)

have not tested code, please tell me if there are any errors

2 comments

0

set your billboard position

0

there was a little problem with the serverscript code but its ok now tsym

This discussion is preserved as it was. New answers, comments, and votes are closed.