Not sure if this is suppose to be a “bug report”, but whenever i call math.random
to generate a number below 1 (i.e math.random(0.7,0.9)
) it always returns 0. I’m trying to make a coin gui that goes up the screen whenever u get a coin. heres what i have
local SoundService = game:GetService("SoundService")
repeat wait() until Client:FindFirstChild("leaderstats") and Client.leaderstats:FindFirstChild("Coins")
local lastval = Client.leaderstats.Coins.Value
Client.leaderstats.Coins:GetPropertyChangedSignal("Value"):Connect(function()
local newval = Client.leaderstats.Coins.Value
if newval > lastval then
local change = newval - lastval
local ScreenGui = script.AddCoinsFrame:Clone()
local MainFrame = ScreenGui.MainFrame
ScreenGui.Parent = Client.PlayerGui
local x = math.random(0.1,0.9)
MainFrame.Position = UDim2.new(x,0,math.random(0.7,0.9),0)
MainFrame.Amount.Text = "+"..change
SoundService:PlayLocalSound(game.ReplicatedStorage.Client.Sounds.CoinCollect)
local t = 1
MainFrame:TweenPosition(UDim2.new(x,0,math.random(0.1,0.3),0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,t)
wait(t)
ScreenGui:Destroy()
end
lastval = newval
end)