It's ment to be a little dice game triggerd from a button but there are some functions such as GeneratePosition():20 and GenerateOrientation():32 that gives me errors. here is the code:
--Variables
local Button = game.Workspace.Button
local ClickDetector = Button.ClickDetector
local Dice1 = game.Workspace.Dices.Dice1
local Dice2 = game.Workspace.Dices.Dice2
--Functions
--Button
function ButtonPress()
Button.Position = Vector3.new(32.243, 10.758, 20.960)
Button.Material = ("Neon")
end
function ButtonRelease()
Button.Position = Vector3.new(32.243, 10.758, 20.441)
Button.Material = ("Plastic")
end
--Dices
function GeneratePosition()
local X1 = math.random(-17, -19)
local Y1 = math.random(42, 44)
local Z1 = math.random(-29, -31)
local X2 = math.random(-13, -15)
local Y2 = math.random(36, 38)
local Z2 = math.random(-25, -27)
Dice1.Position = Vector3.new(X1, Y2, Z1)
Dice2.Position = Vector3.new(X2, Y2, Z2)
end
function GenerateOrientation()
Dice1.Orientation.X = math.random(0, 90)
Dice1.Orientation.Y = math.random(0, 90)
Dice1.Orientation.Z = math.random(0, 90)
Dice1.Orientation.X = math.random(0, 90)
Dice1.Orientation.Y = math.random(0, 90)
Dice1.Orientation.Z = math.random(0, 90)
end
function DicesAnchoredFalse()
Dice1.Anchored = false
wait(0.2)
Dice1.Anchored = false
end
function DicesAnchoredTrue()
Dice1.Anchored = true
Dice2.Anchored = true
end
--Event
ClickDetector.MouseClick:Connect(function()
ButtonPress()
DicesAnchoredTrue()
GeneratePosition()
GenerateOrientation()
wait(1)
ButtonRelease()
DicesAnchoredFalse()
end)
