Gui Tweening only once

So i saw a very similar question like this in this topic:

And i kinda understand what i can’t do it.

I’m trying to make a note system, there is a page on a table and when you click on it a gui will appear and when you close it it will move off the screen, but it only does this once.
I know its something to do with local/server scripts.

This is the opening script i think it’s suppose to be client side but i don’t know how too make it that way it is in a normal script:

local paper = game.Workspace.Paper

paper.ClickDetector.MouseClick:Connect(function(plr)
	plr.PlayerGui.ScreenGui.Frame:TweenPosition(UDim2.new(0.363, 0,0.172, 0), "Out", "Quad", 0.5, true)
	print("Paper was clicked")
end)

This is the closing code it is in a local script:

local close = script.Parent.Frame.TextButton
local frame = script.Parent.Frame
close.Activated:Connect(function()
	frame:TweenPosition(UDim2.new(0.363, 0,1, 0), "Out","Quad", 0.5, true)
	game.Workspace.pop:Play()
end)

close.MouseEnter:Connect(function()
	close.TextColor3 = Color3.fromRGB(255,0,4)
end)

close.MouseLeave:Connect(function()
	close.TextColor3 = Color3.fromRGB(0,0,0)
end)

This is what happens:
robloxapp-20200521-1613073.wmv (1.8 MB)

1 Like

Firstly, you should not control UI from the server. It should be done from the client. The reason it only works once is that you tween it (changing position) on the client, which doesnt replicate to the server meaning that for the server, the position of the gui is still at it’s open position.

Yes i knew that but how would i make it on the client?

1 Like

Using remotes
edit: You can also shift the entire clickdetector code to the client in a localscript

Thanks i will look into that.

When you say shift the clickdetector code to a locals script do you mean literally just copying and pasting in a local script?

Yeah, since you can detect the event from either local script or script. If you directly copy + paste, it should still work (but no need to get the player, since you can get the local player from the player service)

For simplicity, paste it into the closing script. Also, you may just be doing it for testing but I wouldn’t recommend calling your UI objects their default names.

Yeah i was doing that for test i never do that normally.

Thank you, very much Joyniser (30)

1 Like