Hello! I was trying to use Udim2 for placing a frame randomly on the gamers screen. So it would appear in different spots. I received no errors, but it doesn’t work.
local db = false
local tableofContent = {
"Fish",
"Fish1"
}
script.Parent.MouseButton1Click:Connect(function()
if db == false then
db = true
task.wait(math.random(4,6))
db = false
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Position = UDim2.new(math.random(0.5,0),0,math.random(0.9,0),0)
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Visible = true
task.wait(1.5)
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Visible = false
end
end)
math.random uses a minimum and a maximum value, the ones you gave are not, and decimals do not work either, and I suppose you try to change between any of them, do this
local X,Y = {0.5,0}, {0.9,0}
local db = false
local tableofContent = {
"Fish",
"Fish1"
}
script.Parent.MouseButton1Click:Connect(function()
if db == false then
db = true
task.wait(math.random(4,6))
db = false
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Position = UDim2.new(X[math.random(#X)],0,Y[math.random(#Y)],0)
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Visible = true
task.wait(1.5)
script.Parent.Parent.Parent.Parent:WaitForChild("FishingLocator"):WaitForChild("TextButton").Visible = false
end
end)