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

BIG PROBLEM!!! What should I do?

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

✓ Accepted answer

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)

1 comment

0

It works! Thank you!

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