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

Tween Gui ontouch part?

Not sure it's possible but so errors show while testing this script?

function move(Gui)
game.StarterGui.GuiMain.Frame:TweenPosition(UDim2.new(0.001,0,0,0),"Out", "Quad", .9)
end
function onTouch(part)
move(script.Parent) 

end

I'ma bit new to tweening, any tips on tweening would help me!

2 answers

I don't know if it's when you hit a part in Workspace, but if it is then this works

function move(Gui)
game.StarterGui.GuiMain.Frame:TweenPosition(UDim2.new(0.001,0,0,0),"Out", "Quad", .9)
end

function onTouch(part)
move(script.Parent) 
end

game.workspace.PARTNAMEHERE.Touched:connect(onTouch)

1 comment

0

Doesn't work?

I'm not sure if you included a listener on the .Touched event.

I think you meant:

yourPart = game.Workspace.ExamplePart;

function move(Gui)
Gui:TweenPosition(UDim2.new(0.001,0,0,0),"Out", "Quad", .9)
end
function onTouch(part)
move(script.Parent) 
end

yourPart.Touched:connect(onTouch);

Also, I would suggest putting the tweening function into a LocalScript and the touched listener into a normal script or else it might not work correctly. I would suggest allowing the normal script to call the tweening function using a remote event.

7 comments

0

How would I do that? I never used RemoteEvents before >.<

0

Go onto the wiki and search it. There's a good tutorial on it. You could probablly just CP most of the code.

0

It's very confusing for me >.< I'm not sure which to use for this script.

0

What do you mean which to use? You will need a localscript and a normal script. You will need a RemoteEvent in the local script.

0

Like using RemoteEvents, the information on the wiki

0

Is that a question? If so, I don't uderstand what you're asking.

0

Ignore What I said before, I was confused on these parts: Location of the local script, and the OnTouched function. I think the OnTouched has to be fixed, but how to, er fix it...

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