: attempt to index string with 'TextTransparency'?

I’ve been working on a piece of code that teleports you when you click, more specifically the GUI that displays the cooldown.

The error that I keep receiving is " attempt to index string with ‘TextTransparency’ ".
And i do not know how to fix it.

Full script:

local char = script.Parent
local humanoid =  char.HumanoidRootPart

local player = game:GetService("Players").LocalPlayer

local debounce = true

local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()

local position = mouse.Hit.Position

local function FireServer()
	game:GetService("ReplicatedStorage").ClickToTeleportEvent:FireServer(position)
end

if debounce == true then
	
	debounce = false
	
	FireServer()
	
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text.TextTransparency = true
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text.BackgroundTransparency = 
true
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text = "CoolDown: 2"
	
	wait(1)
	
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text = "CoolDown: 1"
	
	wait(1)
	
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text = "CoolDown: 0"
	
	wait(1)
	
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text.TextTransparency = false
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text.BackgroundTransparency = 
false
	player.PlayerGui.ClickToTeleportGui.TextLabel.Text = "CoolDown: 2"
	
	debounce = true
	
end 

end)

Transparency properties interprets a number from 0 to 1, 1 is transparent and 0 is opaque.

1 Like

It still says the same error, I did change it to:

player.PlayerGui.ClickToTeleportGui.TextLabel.Text.TextTransparency = 0 
player.PlayerGui.ClickToTeleportGui.TextLabel.Text.BackgroundTransparency = 0

-thanks

The texttransparency property is from the textlabel, not the text.

1 Like

I am very silly, thank you for helping me.

Unrelated to the topic, but doing a for loop would be better than manually changing the text every second and would be more customizable.

The problem is a very simple mistake.

player.PlayerGui.ClickToTeleportGui.TextLabel.TextTransparency = 0
	player.PlayerGui.ClickToTeleportGui.TextLabel.BackgroundTransparency = 0

And the reason this will fix the problem is because these properties are from 0 to 1, and aren’t true or false.

I hope this fixes your issue!