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

Script Won't Work ?[UNANSWERED FOR 3 DAYS]

Hi, I made a Gui script, It's meant to change the text and font whenever it's clicked: If the text is ""Teleport to Bottom (Draggable)" then it should change the text to "Teleport to Top", But the text doesn't change at all and I don't know why!

local tel = script.Parent
local Tel = game.Workspace.Tel1
function Click(Mouse)
    local plr = game.Players.LocalPlayer
    local character = plr.Character
    character:MoveTo(Tel.Position)
    if (tel.Text == "Teleport to Bottom (Draggable)") and (tel.FontSize == "Size11") then
        tel.Text = "Teleport to Top"
        tel.FontSize = "Size12"
    elseif tel.Text == "Teleport to Top" and tel.FontSize == "Size12" then
        tel.Text = "Teleport to Top"
        tel.FontSize = "Size12"
    end
end
tel.MouseButton1Down:connect(Click)

Thanks for the help :P

1 answer

✓ Accepted answer

The problem is you can't check tel.FontSize with a string. You instead must use tel.FontSize == Enum.FontSize.Size11

This is my version of your script. Not sure if it makes more sense as to what your script is supposed to do...

local tel = script.Parent
local TopTele = game.Workspace.Tel1
local BottomTele = game.Workspace.Tel2

function Click(Mouse)
	local plr = game.Players.LocalPlayer
	local character = plr.Character
   
	if (tel.Text == "Teleport to Bottom (Draggable)") and (tel.FontSize == Enum.FontSize.Size11) then
		character:MoveTo(BottomTele.Position)
		tel.Text = "Teleport to Top"
		tel.FontSize = "Size12"
	else
		character:MoveTo(TopTele.Position)
		tel.Text = "Teleport to Bottom (Draggable)"
		tel.FontSize = "Size11"
	end

end
tel.MouseButton1Down:connect(Click)


UPDATE If you ever need to know what Enum you need to use, just type this in the command bar:

print(tostring(game.Workspace.Object.FontSize))

2 comments

0

Thanks, I didn't anything about Enum, Guess that's what confused me.

0

No problem!

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