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

How do I make this resize and change position with text changing too?

Asked by 5 years ago

I'm trying to make a configuration for a phone that will change the size, position, and change the button's text. Nothing changes at all.

local value = script.Parent.Clicks 
local text = script.Parent 
local phone = script.Parent.Parent.PhoneTemplate 

text.MouseButton1Click:Connect(function()

    value.Value = value.Value + 1 
end) 

value.Changed:Connect(function(new)
    if new == 1 then
        text.Text = "Width (1/3)"
phone.Size = {0, 250},{0, 396}
phone.Position = {0.4, 0},{0.19, 0} --Poisition is here because without it the screen would get messed up
    elseif new == 2 then
       text.Text = "Width (2/3)"
phone.Size = {0, 260},{0, 396}
phone.Position ={0.396, 0},{0.19, 0}
    elseif new == 3 then
       text.Text = "Width (3/3)"
phone.Size = {0, 270},{0, 396}
phone.Position = {0.394, 0},{0.19, 0} 
    elseif new > 3 then
        text.Text = "Width (1/3)"
        value.Value = 1
    end
end)

Thanks if you can help.

1 answer

Log in to vote
2
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

That's not how you set position. You need to use UDim2 for it.

local value = script.Parent.Clicks 
local text = script.Parent 
local phone = script.Parent.Parent.PhoneTemplate 

text.MouseButton1Click:Connect(function()

    value.Value = value.Value + 1 
end) 

value.Changed:Connect(function(new)
    if new == 1 then
        text.Text = "Width (1/3)"
phone.Size = UDim2.new(0, 250, 0, 396)
phone.Position = UDim2.new(0.4, 0, 0.19, 0)
    elseif new == 2 then
       text.Text = "Width (2/3)"
phone.Size = UDim2.new(0, 260, 0, 396)
phone.Position =UDim2.new(0.396, 0, 0.19, 0)
    elseif new == 3 then
       text.Text = "Width (3/3)"
phone.Size = Udim2.new(0, 270, 0, 396)
phone.Position = UDim2.new(0.394, 0, 0.19, 0) 
    elseif new > 3 then
        text.Text = "Width (1/3)"
        value.Value = 1
    end
end)

0
Nothing changes still. CaptainAlien132 225 — 5y
0
Nevermind, I messed something up with the value. CaptainAlien132 225 — 5y
Ad

Answer this question