Main Code:
local Holder = script.Parent.Holder
local DecButton = Holder.Decrease
local IncButton = Holder.Increase
local HeightButton = Holder.HeightButton
local mouseHeld = false
local GetHeight = game:GetService("ReplicatedStorage").RemoteFunctions.GetHeight
local SelectedHeight = GetHeight:InvokeServer() -- Starting height when player joins
local HeightChangeInterval = 0.0254 -- 1in in meters
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = false
end
end)
local function FormatHeightDisplay(HeightInMeters)
local feet = HeightInMeters * 3.28084
local inches = math.floor((feet - math.floor(feet)) * 12)
local totalInches = math.round(HeightInMeters * 39.37)
feet = math.floor(feet)
local RoundedMeters = math.floor(HeightInMeters * 100 + 0.5) / 100 -- Round to 2 decimal places
return tostring(feet) .. "'" .. inches .. '" / ' .. tostring(RoundedMeters) .. "m / " .. tostring(totalInches) .. "in"
end
local CurrentHeight = script.Parent.CurrentHeight
HeightButton.Text = FormatHeightDisplay(GetHeight:InvokeServer())
CurrentHeight.Text = FormatHeightDisplay(GetHeight:InvokeServer())
DecButton.MouseEnter:Connect(function()
DecButton.Outline.Enabled = true
end)
DecButton.MouseLeave:Connect(function()
DecButton.Outline.Enabled = false
end)
IncButton.MouseEnter:Connect(function()
IncButton.Outline.Enabled = true
end)
IncButton.MouseLeave:Connect(function()
IncButton.Outline.Enabled = false
end)
HeightButton.MouseEnter:Connect(function()
HeightButton.Outline.Enabled = true
end)
HeightButton.MouseLeave:Connect(function()
HeightButton.Outline.Enabled = false
end)
IncButton.MouseButton1Down:Connect(function()
task.wait(0.5)
if mouseHeld then
repeat
SelectedHeight += HeightChangeInterval
HeightButton.Text = FormatHeightDisplay(SelectedHeight)
local PlrCurrentHeight = GetHeight:InvokeServer()
if PlrCurrentHeight < SelectedHeight or PlrCurrentHeight > SelectedHeight then
if CurrentHeight.Visible == false then CurrentHeight.Visible = true end
CurrentHeight.Text = FormatHeightDisplay(PlrCurrentHeight)
else
if CurrentHeight.Visible == true then CurrentHeight.Visible = false end
end
task.wait(0.15)
until mouseHeld == false
end
end)
DecButton.MouseButton1Down:Connect(function()
task.wait(0.5)
if mouseHeld then
repeat
SelectedHeight -= HeightChangeInterval
HeightButton.Text = FormatHeightDisplay(SelectedHeight)
local PlrCurrentHeight = GetHeight:InvokeServer()
if PlrCurrentHeight < SelectedHeight or PlrCurrentHeight > SelectedHeight then
if CurrentHeight.Visible == false then CurrentHeight.Visible = true end
CurrentHeight.Text = FormatHeightDisplay(PlrCurrentHeight)
else
if CurrentHeight.Visible == true then CurrentHeight.Visible = false end
end
task.wait(0.15)
until mouseHeld == false
end
end)
IncButton.MouseButton1Click:Connect(function()
SelectedHeight += HeightChangeInterval
HeightButton.Text = FormatHeightDisplay(SelectedHeight)
local PlrCurrentHeight = GetHeight:InvokeServer()
if PlrCurrentHeight < SelectedHeight or PlrCurrentHeight > SelectedHeight then
if CurrentHeight.Visible == false then CurrentHeight.Visible = true end
CurrentHeight.Text = FormatHeightDisplay(PlrCurrentHeight)
else
if CurrentHeight.Visible == true then CurrentHeight.Visible = false end
end
end)
DecButton.MouseButton1Click:Connect(function()
SelectedHeight -= HeightChangeInterval
HeightButton.Text = FormatHeightDisplay(SelectedHeight)
local PlrCurrentHeight = GetHeight:InvokeServer()
if PlrCurrentHeight < SelectedHeight or PlrCurrentHeight > SelectedHeight then
if CurrentHeight.Visible == false then CurrentHeight.Visible = true end
CurrentHeight.Text = FormatHeightDisplay(PlrCurrentHeight)
else
if CurrentHeight.Visible == true then CurrentHeight.Visible = false end
end
end)
local SetHeight = game:GetService("ReplicatedStorage").RemoteEvents.SetHeight
local db = false
local CooldownBar = HeightButton.CooldownBarHolder.CooldownBar
HeightButton.MouseButton1Click:Connect(function()
local PlrCurrentHeight = GetHeight:InvokeServer()
if db == false and SelectedHeight < PlrCurrentHeight or SelectedHeight > PlrCurrentHeight then
db = true
CurrentHeight.Visible = false
SetHeight:FireServer(SelectedHeight)
local TS = game:GetService("TweenService")
CooldownBar.Visible = true
TS:Create(CooldownBar,TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size = UDim2.new(0,0,1,0)}):Play()
task.wait(3)
CooldownBar.Visible = false
CooldownBar.Size = UDim2.new(1,0,1,0)
db = false
end
end)
The issue is that whenever I change the text on the CurrentHeight it shifts a little so its way off its original position although no position-changing code is in the script and no Automatic Size is not enabled.