What I want to happen is that each time the text button is clicked, it appears in a random spot on the screen and you click it again and it just repeats
I tried looking through devforum for something similar and I just found this…
Random Script
> local r = Random.new()
>
> local function GetRandomPosition()
> return UDim2.new(r:NextNumber(0,1),0,r:NextNumber(0,1),0)
> end
I’m honestly kind of stuck on where I should go from here.
I need the Dice to appear somewhere else on the screen beside that single spot.
I also have this script that is the popup that appear when you click the button.
I wondering if it could be rewritten for the button.
PopUp Script
> click = 0
> local plr = game.Players.LocalPlayer
> while wait() do
> if click ~= plr.leaderstats.Points.Value then
> local random = math.random(1,1000)
> local xnew = random/1000
> local new = game.ReplicatedStorage.ShowDice:Clone()
> new.Parent = script.Parent.Main
> new.Position = UDim2.new(xnew,0,1,0)
> new.Text = ""..plr.leaderstats.Points.Value - click.."🎲"
> click = plr.leaderstats.Points.Value
> end
> end
I tried a click function
but didn’t work
Click Function
function leftClick()
local random = math.random(1,1000)
local xnew = random/1000
local new = game.ReplicatedStorage.TextButton:Clone()
new.Parent = script.Parent.Main
new.Position = UDim2.new(xnew,0,1,0)
end
script.Parent.MouseButton1Click:Connect(leftClick)
So I added this in the TextButton Local Script in StarterGui and it seem to did something.
New Script
script.Parent.Activated:Connect(function()
game.Workspace.MainEvent.AddPoint:FireServer()
script.Parent.Parent.Enabled = false
wait(1)
script.Parent.Parent.Enabled = true
wait()
script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X,0, -0.1, 0))
wait()
for i = 1,20 do
local random = math.random(1,1000)
local xnew = random/1000
local new = game.ReplicatedStorage.TextButton:Clone()
new.Parent = script.Parent.Main
script.Parent.Position = UDim2.new(xnew,0,1,0)
wait()
end
end)
Trying out some TweenPosition