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

How do I make this Argument work properly?

Hi, I made this script for a Gui, It's function is to Teleport whoever clicks the Gui to a Part, But It's also ment to the change the text of the TextButton, so if the text is "Teleport to Top" then it's ment to change it is "Teleport to Bottom" when the Gui is clicked. can anyone help me because the text stays the same:

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)

3 comments

0

Edited.

0

Edited v2, Please edit my script, I might have your Hierachy wrong.

0

No Difference still won't work

1 answer

Your One and Only Problem

The one and only problem is that, you are checking a Enumeration(Enum) Property using strings.


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 == Enum.FontSize.Size11) then
        tel.Text = "Teleport to Top"
        tel.FontSize = "Size12" -- setting a Enum Property using strings is fine,but checking a Enum Property using strings is invalid.
    elseif tel.Text == "Teleport to Top" and tel.FontSize == Enum.FontSize.Size12 then
        tel.Text = "Teleport to Bottom (Draggable)"
        tel.FontSize = "Size11"
    end
end
tel.MouseButton1Down:connect(Click)

2 comments

0

It doesn't work, did you read the whole Description?

0

I know you edited but it doesn't make a a difference, It still won't work.

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