Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by
Aimarekin 345 Moderation Voter
2 years ago

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)
0
It does not work jakubiscool5 8 — 2y
0
Please be more specific - how exactly does it not work? Are there errors in the output? Aimarekin 345 — 2y
0
The script does nothing for some reason. jakubiscool5 8 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
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.

Answer this question