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

BIG PROBLEM!!! What should I do?

Asked by 9 years ago

I'm trying to tween a Frame. However, when I was testing it only the button changed and the Frame did not move. Is there a problem in the script below? (This is a local script)

01local frame = game.StarterGui.FrameGui.Frame
02local button = script.Parent
03local toggle = false
04script.Parent.MouseButton1Click:connect(function()
05    if toggle == false then
06        toggle = true
07        frame:TweenPosition(UDim2.new(0.25,-50,0.4,-50),'Out','Quad',1)
08        script.Parent.Text = 'Close Shop'
09    else
10        toggle = false
11        frame:TweenPosition(UDim2.new(0.25,-50,1.4,-50), 'In', 'Quad',1)
12        script.Parent.Text = 'Open Shop'
13    end
14end)

Here is the link to the problem. Please watch.

1 answer

Log in to vote
1
Answered by
DevSean 270 Moderation Voter
9 years ago

The problem is your linking to the frame in the StarterGui, you need to link to the frame which is the parent of the button.

01local frame = script.Parent.Parent -- I'm guessing the frame is the button's parent...?
02local button = script.Parent
03local toggle = false
04script.Parent.MouseButton1Click:connect(function()
05    if toggle == false then
06        toggle = true
07        frame:TweenPosition(UDim2.new(0.25,-50,0.4,-50),'Out','Quad',1)
08        script.Parent.Text = 'Close Shop'
09    else
10        toggle = false
11        frame:TweenPosition(UDim2.new(0.25,-50,1.4,-50), 'In', 'Quad',1)
12        script.Parent.Text = 'Open Shop'
13    end
14end)
0
It works! Thank you! starlebVerse 685 — 9y
Ad

Answer this question