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

Frame not sizing or positioning when told to by script?!

So, I have this function and it creates a frame onto an existing one. The existing frame is registered and all that good stuff, but when I try to resize and reposition the new frame with the existing frames size and position it doesn't work. No errors, just a frame that is at {0,0,0,0} size and {0,0,0,0} position. Here is the code:

function createWhite(lastFrame)
	local frameToGet = Bars:FindFirstChild(tostring(lastFrame))
	local frame = Instance.new("Frame", script.Parent.ImageLabel["Bar Frames"])
	frame.Visible = true
	frame.Name = "ShootingFrame"
	frame.BackgroundColor3 = Color3.new(255/255,255/255,255/255) --// White
	frame:TweenSize(UDim2.new(frameToGet.Size))
	frame:TweenPosition(UDim2.new(frameToGet.Position))
	frame.Rotation = frameToGet.Rotation
	frame.ZIndex = 3
	lastSpotVal = frameToGet.SpotValue.Value
end

1 answer

✓ Accepted answer

Inside your TweenSize and TweenPosition calls, you call the UDim2 constructor, UDim2.new. All you need to do is remove that, and just use the Size and Position of frameToGet, as they're already UDim2 values.

function createWhite(lastFrame)
    local frameToGet = Bars:FindFirstChild(tostring(lastFrame))
    local frame = Instance.new("Frame", script.Parent.ImageLabel["Bar Frames"])
    frame.Visible = true
    frame.Name = "ShootingFrame"
    frame.BackgroundColor3 = Color3.new(255/255,255/255,255/255) --// White
    frame:TweenSize(frameToGet.Size)
    frame:TweenPosition(frameToGet.Position)
    frame.Rotation = frameToGet.Rotation
    frame.ZIndex = 3
    lastSpotVal = frameToGet.SpotValue.Value
end

Hope this helped.

2 comments

0

Helped a lot! Thanks. Cannot believe I overlooked that haha.

0

No problem.

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