I have a score variable holding a value of 0, I want the value to be printed onto a script inside a TextLabel in StarterGui.
Score = 0 local clickdetector = script.Parent:WaitForChild("ClickDetector") math.random(tick()) clickdetector.MouseClick:Connect(function() script.Parent.Position = Vector3.new(math.random(20, 70),math.random(10, 20),math.random(20, 70)) Score = Score + 1 print(Score) end)
local ScreenGui = script:FindFirstAncestorWhichIsA("ScreenGui") local TextLabel = ScreenGui:FindFirstChildWhichIsA("TextLabel") TextLabel.Text =
Use number values (https://developer.roblox.com/en-us/api-reference/class/NumberValue). Here's an example.
Score = 0 local clickdetector = script.Parent:WaitForChild("ClickDetector") local NumberValue = Instance.new("NumberValue") NumberValue.Name = "Number" NumberValue.Parent = game.ReplicatedStorage math.random(tick()) clickdetector.MouseClick:Connect(function() script.Parent.Position = Vector3.new(math.random(20, 70),math.random(10, 20),math.random(20, 70)) Score = Score + 1 local NumberValue = Instance.new("NumberValue") NumberValue.Value = Score end)
local ScreenGui = script:FindFirstAncestorWhichIsA("ScreenGui") local TextLabel = ScreenGui:FindFirstChildWhichIsA("TextLabel") local NV = game.ReplicatedStorage:FindFirstChild("Number") TextLabel.Text = NV.Value