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

how to make it so when iclick a button with the script below it does the thing in the script?

My local script does not work

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Visible = false
	then

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

	script.Parent.MouseButton1Click:connect(function()
		TeleportService:Teleport(Place, player)
		then
	
	local frame = script.Parent.Parent.Info
	local open = false

	script.Parent.MouseButton1Click:Connect(function()
		if frame.Visible == false then
			frame.Visible = true
		end)
	end)
	end)
end)

2 answers

✓ Accepted answer

What are the thens at lines 3 and 11 for? They should be removed - they cause a SyntaxError.

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Parent.Visible = false

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

    script.Parent.MouseButton1Click:connect(function()
        TeleportService:Teleport(Place, player)

        local frame = script.Parent.Parent.Info
        local open = false

        script.Parent.MouseButton1Click:Connect(function()
            if frame.Visible == false then
                frame.Visible = true
            end)
        end)
    end)
end)

3 comments

0

It does not work

0

Please be more specific - how exactly does it not work? Are there errors in the output?

0

The script does nothing for some reason.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Visible = false

	local TeleportService = game:GetService("TeleportService")
	local Place = 9046212678
	local player = game:GetService("Players").LocalPlayer
	
	TeleportService:Teleport(Place, player)

	local frame = script.Parent.Parent.Info

	if frame.Visible == false then
		frame.Visible = true
	end
end)

Just like Aimarekin said, your original script includes syntax errors at line 3, and line 11. then should only be used in if statements. (ex. if value then end)

Your original script also connects the same function inside the same function. Why would you want to connect the same function inside the same function when you already have a main function that detects the clicks? Those unnecessary functions should be removed.

I don't know why you have a variable called open even though it's not being used.

Please let me know if you have any further issues.

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