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

Move GUI Position onTouch not working?!

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

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)

2 comments

0

Thank you so much for teaching me about Tweening! Now i became even better scripter! (Intermediate)

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.

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