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 8 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)

local frame = game.StarterGui.FrameGui.Frame
local button = script.Parent
local toggle = false
script.Parent.MouseButton1Click:connect(function()
    if toggle == false then
        toggle = true
        frame:TweenPosition(UDim2.new(0.25,-50,0.4,-50),'Out','Quad',1)
        script.Parent.Text = 'Close Shop'
    else
        toggle = false
        frame:TweenPosition(UDim2.new(0.25,-50,1.4,-50), 'In', 'Quad',1)
        script.Parent.Text = 'Open Shop'
    end
end)

Here is the link to the problem. Please watch.

1 answer

Log in to vote
1
Answered by
DevSean 270 Moderation Voter
8 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.

local frame = script.Parent.Parent -- I'm guessing the frame is the button's parent...?
local button = script.Parent
local toggle = false
script.Parent.MouseButton1Click:connect(function()
    if toggle == false then
        toggle = true
        frame:TweenPosition(UDim2.new(0.25,-50,0.4,-50),'Out','Quad',1)
        script.Parent.Text = 'Close Shop'
    else
        toggle = false
        frame:TweenPosition(UDim2.new(0.25,-50,1.4,-50), 'In', 'Quad',1)
        script.Parent.Text = 'Open Shop'
    end
end)
0
It works! Thank you! starlebVerse 685 — 8y
Ad

Answer this question