[SOLVED] New to scripting, how would I fix this?

I’m currently making a loading screen and I wanted to add random text froma table as tips on the bottom of the loading screen. It seems to error at the tips with the error “Unable to assign property Text. string expected, got boolean”.

-------- SERVICES --------

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

-------- LOADING UI --------
local Loading = Instance.new("ScreenGui")
Loading.Name = "Loading"
Loading.Parent = Players.LocalPlayer.PlayerGui

local LoadingFrame = Instance.new("Frame") -- Frame itself
LoadingFrame.Name = "LoadingFrame"
LoadingFrame.Size = UDim2.new(1, 0, 1, 0)
LoadingFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
LoadingFrame.AnchorPoint = Vector2.new(0.5, 0.5)
LoadingFrame.Parent = Loading

local Gradient = script:FindFirstChild("Dark") --Gradient for  loading BG
Gradient.Parent = LoadingFrame

local Tip = Instance.new("TextLabel")
Tip.Parent = LoadingFrame
Tip.TextColor3 = Color3.new(0.917647, 0.988235, 1)
Tip.BackgroundTransparency = 1
Tip.Size = UDim2.new(0.312, 0, 0.085, 0) 
Tip.Position = UDim2.new(0.334, 0, 0.746, 0)
local PossibleTips = {
	"preset tip" == 1,
	"Tip 2" == 2,
	"Tip 3" == 3
}
tip = math.random(1, 3)
if tip == 1 then
	Tip.Text = PossibleTips[1]
elseif tip == 2 then
	Tip.Text = PossibleTips[2]
elseif tip == 3 then
	Tip.Text = PossibleTips[3]
end

local Logo = Instance.new("ImageLabel") -- Center Logo
Logo.BackgroundTransparency = 1
Logo.Image = "rbxassetid://98283397969117"
Logo.ImageColor3 = Color3.new(255, 0, 0)
Logo.Position = UDim2.new(0.401, 0, 0.324, 0)
Logo.Size = UDim2.new(0.197, 0, 0.354, 0)
Logo.Parent = LoadingFrame
local Constraint = script:FindFirstChild("UIAspectRatioConstraint")
Constraint.Parent = Logo

local Red = script:FindFirstChild("Red") -- Gradient 2
Red.Parent = Logo and Tip

-------- ROTATION --------

task.spawn(function()
	while Loading and Loading.Parent do 
		Logo.Rotation = (Logo.Rotation >= 360 and 0) or Logo.Rotation + 2
		task.wait()
	end
end)

ReplicatedFirst:RemoveDefaultLoadingScreen()

-------- TWEENING --------

task.wait(5)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local FrameTween = TweenService:Create(LoadingFrame, tweenInfo, {Transparency = 1})
local LogoTween = TweenService:Create(Logo, tweenInfo, {Transparency = 1})
FrameTween:Play()
LogoTween:Play()
FrameTween.Completed:Wait()
LogoTween.Completed:Wait()
Loading:Destroy()
1 Like

you’re using the == operator. This basically checks if one thing is equal to another

So it’s comparing “preset tip” to the number 1

“present tip” (string) is NOT equal to 1 (number) so it returns false (a Boolean)

and it’s NOT setting “present tip” to 1

What you can do is probably just create an array (a table with just values, not setting variables / words to values

local PossibleTips = {
   "preset tip",
   "Tip 2",
   "Tip3"
}

Tried the last way, same error but now its nil.

1 Like

Oh shoot my bad I meant this:

local PossibleTips = {
   "preset tip", "Tip 2", "Tip3"
}

Each value in the table has a number assigned to it (its index) based on the order you place it in

so… you don’t really need to assign a number

"preset tip", "Tip 2", "Tip 3"
--  1              2          3

print(table[1])
-> preset tip

you can use this

local PossibleTips = {
	"random",
	"tips",
	"table"
}

Tip.Text = PossibleTips[math.random(1, #PossibleTips)]
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.