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

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

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

✓ Accepted answer

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)

1 comment

0

thank you!!

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

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