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

i have a problem with the buttondown1 function, how do i use it correctly?

Asked by 3 years ago

i have tried several times to get the buttondown1 function to work. Im using this function for a text button, for a menu that after pressing 'play' it teleports the player to the selected location.

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Put this script inside of your button, and change the print to do whatever you need.

local btn = script.Parent

btn.MouseButton1Click:Connect(function()
    print('clicked')
end)
0
thank you!! destroyermagical13 2 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Put this in a LocalScript, then parent the localscript to the button. Change "TPpart" to the name of the part you want the player to teleport to when they click the button. Make sure CanCollide is set to false else the player can get stuck.

script.Parent.MouseButton1Click:Connect(function()
    local player = game.Players.LocalPlayer
    player.Character.HumanoidRootPart.CFrame = game.Workspace.TPpart.CFrame
    -- Change "TPpart" to the name of the part. --
end)

Video demo of script in use: https://imgur.com/a/gLmIXxv

Answer this question