I am trying to make a script that will unlock a button to teleport. I unselected selectable under property’s and I could still select it. When you click it it does disapear
If you want my code here it is
function OnClicked()
script.Parent.Parent.Parent.Parent:Remove()
script.Parent.Parent.Parent.Parent.Parent.Selectable = true
end
script.Parent.MouseButton1Down:connect(OnClicked)
How does the player unlock the teleport functionality?
Regardless, here is a sample of what you’d want to do (based on what you provided as your desire/goal)
local plr = game.Players.LocalPlayer
function OnClicked()
script.Parent.Parent.Parent.Parent:Remove()
plr.Character.HumanoidRootPart.Position = —Use Vector3 or CFrame to change the position of the player
end
script.Parent.MouseButton1Down:Connect(OnClicked)
Create an if then statement between the function OnClicked() and script.parent.parent.parent.parent:Remove() to check if the player has the requirement (if there is a requirement).
I believe connect() is depreciated in favor of Connect() so I changed it.
There are differences between Remove() and Destroy() in which remove sets the parent to nil while Destroy sets the parent to nil, disconnects all connections on the object’s events, and locks the parent property. Depending on your use of the button, you’d want to choose from these two options.
I can provide a better code sample, but I need to know if the teleport has a requirement.