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

Move GUI Position onTouch not working?!

Asked by
Jurdy 0
9 years ago

Doesn't make it slide, or do anything. Please help!

debounce = false

script.Parent.Touched:connect(function(hit)
    if debounce == false then
        debounce = true
local   humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

-- do stuff
for i = 300, 150, -1 do
    wait(0.5)
    player.PlayerGui.Intro.Window.Position = UDim2.new(0,0,0.5,i)
end
        debounce = false
        end
    end
end)

1 answer

Log in to vote
1
Answered by 9 years ago

Using Loops to slide a Gui doesn't always work so great, so you should try using Tweening. An example, and a possible fix for your script would be this:

Debounce = false

script.Parent.Touched:connect(function(hit)
    if Debounce == false then
        Debounce = true
        local Humanoid = hit.Parent:FindFirstChild("Humanoid")
        if Humanoid then
            local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

            Player.PlayerGui.Intro.Window:TweenPosition(UDim2.new(EndPosition), "Out", "Linear", 1, true, nil)
        end
        Debounce = false
    end
end)
0
Thank you so much for teaching me about Tweening! Now i became even better scripter! (Intermediate) Jurdy 0 — 9y
0
No problem at all! I highly recommend you take a look at the link I provided, as it can help explain what all the things after the Tween represent. Shrekerly 70 — 9y
Ad

Answer this question