I have a problem with math.random. When I use math.random in a function to set the position of GUI, the math.random stays as that math.random. Meaning the first time I fire the function it values at X. But if I fire it a second time, it still values as X. Below is part of the function.
script.Parent.MouseClick:Connect(function(player)
print("clicked")
script.Parent.Parent.Transparency = 1
local Data1 = player:WaitForChild("Data1")
local Data2 = player:WaitForChild("Data2")
local Uncooked = Data1:WaitForChild("UncookedChiikens")
local Multiplier = Data2:WaitForChild("Multiplier")
local GUI = player.PlayerGui:WaitForChild("Add")
local Label = GUI:WaitForChild("Label")
local clone = Label:Clone()
clone.Parent = GUI
clone.Visible = true
clone.Text = "+".. 1 * Multiplier.Value
clone.Position = UDim2.new(math.random(0.100,0.500,0),math.random(0.100,0.500))
script.Parent = script.Parent.Parent
script.Parent.ClickDetector:Destroy()
script.Parent.Deletion:Destroy()
Not sure what you’re trying to do here, but UDim2.new requires 4 Numbers to set in chronological order:
X Scale
X Offset
Y Scale
Y Offset
You can just set clone.Position’s X Scale to math.random(), and since I don’t know what your actual Y Position is, I’ve just set it so only the X Scale will change along with making the Y Scale stationary
In case the scaling is important here, we would want math.random() with no parameters here for this example as this returns a Whole Number between 0.000000000000000-1.000000000000000