What do you want to achieve?
I am trying to make it so that when the player spawns in, the Text on their back changes to a random number, but so that everyone can see it.
What is the issue?
Below this is my code. Right now, it is in the “StarterCharacter”. If the StarterCharacter is in workspace, the code works, but when I put it in StarterPlayer, it does not work, and gives me no errors.
local character = script.Parent
local NumberPart = character.Number
local Number = NumberPart.SurfaceGui.Number
function play()
local JerseyNumber = math.random(1, 100)
print(JerseyNumber)
Number.Text = JerseyNumber
end
What solutions have you tried so far?
Putting it in a LocalScript, it didn’t work.
Right now the script is INSIDE the StarterCharacter, and it is a normal Script, not a LocalScript.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
local NumberPart = character.Number
local Number = NumberPart.SurfaceGui.Number
function play()
local JerseyNumber = math.random(1, 100)
print(JerseyNumber)
Number.Text = JerseyNumber
end
end)
end)
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character
local numberPart = character.Number
local number = numberPart.SurfaceGui.Number
local jerseyNumber = math.random(1,100)
print(jerseyNumber)
number.Text = JerseyNumber
end)
Hey @Qd_awg i have made a better version of your script when everytime you click it picks a number
local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse()
local TextLaber = script.Parent.ScreenGui.Frame.TextLabel -- customize this to your textlabel
mouse.Button1Up:Connect(function()
local JerseyNumber = math.random(1, 100)
print(JerseyNumber)
TextLaber.Text = JerseyNumber
end)