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

Tweened GUI open on touch?

Asked by 6 years ago

I am trying to make a Tweened GUI that will, instead of on click of a button, a part that you touch. I've tried a lot of different scripts, but none seem to work.

The code that I usually use for when I click a button to Tween a Gui is this:

local frame = game.StarterGui.ScreenGui local toggle = false

script.Parent.**MouseButton1Click**:connect(function()
    if toggle == false then 
        frame:TweeningPosition(UDIM2.new(coords), 'Out / In', 'Easing Style', 1)
    toggle = true
else
        frame:TweeningPosition(UDIM2.new(coords), 'Out / In', 'Easing Style', 1)
    toggle = false
    end
end)

* And yes I have tried changing the bold part to Touched.*

Anyways to help?

0
why are you using cords twice? The_Pr0fessor 595 — 6y
0
Use a RemoteEvent. User#19524 175 — 6y

2 answers

Log in to vote
0
Answered by
Ap_inity 112
6 years ago
Edited 6 years ago

You've got some things wrong in there, I'll list them for you:

"TweeningPosition" is written instead "TweenPosition", "UDIM2" is written instead "UDim2", you don't need the commas for the numbers, just use Enum.EasingDirection.InOut, same goes for the easing style: Enum.EasingStyle.Quad, you can't tween entire gui's itself, you need to tween individual frames, and finally, you can use the Touched function, it will work with it.

I've rewritten your script, it should look like this after everything is applied:

script.Parent.Touched:connect(function()
    if toggle == false then 
        frame:TweenPosition(UDim2.new(coords), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1)
        toggle = true
    else
        frame:TweenPosition(UDim2.new(coords), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1)
        toggle = false
    end
end)

Please accept this answer if it helped. If anything is wrong, leave a comment on this answer, and I'll get to you.

0
Do not remind users to accept your answer. If it truly helped, it is nature for them to accept your answer. You're just being greedy. User#19524 175 — 6y
0
It was not greedy of him, he just wanted to be aware if this answer helped. (Sorry for not accepting was very busy and forgot.) thebluepicaxe717 18 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Okay so first off you need to make a server script and put it inside the part.

script.Parent.Touched:connect(function(hit)

end)

So that makes whatever is put inside to run when the part is touched. Assuming the parent of the script is the part.

Next because that is a server script and the server can’t access playergui we need to make a RemoteEvent

assuming the RemoveEvent is in Workspace and is named RemoteEvent we want to do the following inside of what we had.

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.Workspace.RemoteEvent:FireClient(plr) 
end
end)

Now the following will be in a LOCALSCRIPT in starterGui

game.Workspace.RemoteEvent.OnClientEvent:connect(function()
— Put the tween code here. (Remove this line)
end)

Didn’t test this as I am on phone so mind any typing mistakes.

0
Should be using Connect User#19524 175 — 6y

Answer this question