Ulxqra
(Ulxqra)
August 6, 2020, 5:26am
#1
How do I improve my script? So it is supposed to tp you and tween on a screen when you click on a button.
local clicked = false
local TeleportService = game:GetService("TeleportService")
local GameId = 5356825192
local object = script.Parent.Parent.Parent.Blackout
object.AnchorPoint = Vector2.new(0,0)
object.Position = UDim2.new(1, 0, 0, 0)
object.Visible = true
script.Parent.MouseButton1Down:Connect(function()
wait(1)
clicked = true
object.BackgroundTransparency = 0
object:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce)
end)
wait(0.5)
if clicked == true then
TeleportService:Teleport(GameId)
end
3 Likes
Duckzye
(adam)
August 6, 2020, 5:36am
#2
I don’t see exactly what you’re trying to do with this script since it will only try to teleport them once when the local script loads in…
2 Likes
Ulxqra
(Ulxqra)
August 6, 2020, 5:38am
#3
Would the script work?
What would the effects of this do?
1 Like
You should put the wait and teleport into the click function. Currently it is saying clicked is true, but the teleport function already checked for clicked’s value right when the game loaded, making it not teleport you.
1 Like
Ulxqra
(Ulxqra)
August 6, 2020, 5:44am
#5
Would I need the variable ‘clicked’?
2 Likes
Ulxqra:
script.Parent.MouseButton1Down:Connect(function()
wait(1)
clicked = true
object.BackgroundTransparency = 0
object:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce)
end)
wait(0.5)
if clicked == true then
TeleportService:Teleport(GameId)
end
In this chunk you would move this:
Into the click function(also you don’t need the clicked variable), so it would look like this…
script.Parent.MouseButton1Down:Connect(function()
wait(1)
object.BackgroundTransparency = 0
object:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce)
wait(0.5)
TeleportService:Teleport(GameId)
end)
You could also change the Enum.Easing… to just a string
Ulxqra:
object:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce)
So instead of Enum.EasingDirection.Out you could have it as “Out”
1 Like