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!
01 | local tel = script.Parent |
02 | local Tel = game.Workspace.Tel 1 |
03 | function Click(Mouse) |
04 | local plr = game.Players.LocalPlayer |
05 | local character = plr.Character |
06 | character:MoveTo(Tel.Position) |
07 | if (tel.Text = = "Teleport to Bottom (Draggable)" ) and (tel.FontSize = = "Size11" ) then |
08 | tel.Text = "Teleport to Top" |
09 | tel.FontSize = "Size12" |
10 | elseif tel.Text = = "Teleport to Top" and tel.FontSize = = "Size12" then |
11 | tel.Text = "Teleport to Top" |
12 | tel.FontSize = "Size12" |
13 | end |
14 | end |
15 | tel.MouseButton 1 Down:connect(Click) |
Thanks for the help :P
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...
01 | local tel = script.Parent |
02 | local TopTele = game.Workspace.Tel 1 |
03 | local BottomTele = game.Workspace.Tel 2 |
04 |
05 | function Click(Mouse) |
06 | local plr = game.Players.LocalPlayer |
07 | local character = plr.Character |
08 |
09 | if (tel.Text = = "Teleport to Bottom (Draggable)" ) and (tel.FontSize = = Enum.FontSize.Size 11 ) then |
10 | character:MoveTo(BottomTele.Position) |
11 | tel.Text = "Teleport to Top" |
12 | tel.FontSize = "Size12" |
13 | else |
14 | character:MoveTo(TopTele.Position) |
15 | tel.Text = "Teleport to Bottom (Draggable)" |
16 | tel.FontSize = "Size11" |
17 | end |
18 |
19 | end |
20 | tel.MouseButton 1 Down:connect(Click) |
UPDATE If you ever need to know what Enum you need to use, just type this in the command bar:
1 | print ( tostring (game.Workspace.Object.FontSize)) |