I'm having trouble tweening a GUI when a player's character touches a part. It seems that it should be fairly simple, but it has actually proven to be quite challenging. Here is the code I currently have in the part I want the character to touch:
local frame = game.StarterGui:WaitForChild("TeleportOptions").Frame function onTouch() frame:TweenPosition(UDim2.new(0.11, 322, -0.2, 223), "Out", "Quint", 0.9, false) -- Test print statement to indicate that the block is being touched print("Part has been touched") end script.Parent.Touched:Connect(onTouch)
There are no errors showing in the output and the test print statement seems to be working. I'm not sure if it isn't working due to way the frame
variable is being called or if the frame is being tweened too many times while the player touches the part multiple times.
I may be taking the wrong approach to the task, so if there is a better way of achieving the same goal, please let me know.
Hello, Fillipko24!
Your problem is that you're changing StarterGui
and not PlayerGui
, also, you need to grab the character from the part that touched, to be able to get player PlayerGui
function onTouch(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) -- Tryes to grab player from the character if(plr)then--Test if is valid player local frame = plr.PlayerGui:WaitForChild("TeleportOptions").Frame frame:TweenPosition(UDim2.new(0.11, 322, -0.2, 223), "Out", "Quint", 0.9, false) -- Test print statement to indicate that the block is being touched print("Part has been touched") end end script.Parent.Touched:Connect(onTouch)
If I helped please upvote and accept the answer
Useful Links:
Starter Gui - Roblox Developer API