Hey guys, I came on here today to ask how I can make a system like below.
(MAINLY THE EQUATION PART AT THE TOP)
Hey guys, I came on here today to ask how I can make a system like below.
(MAINLY THE EQUATION PART AT THE TOP)
local numberA = math.random(0, 10)
local numberB = math.random(0, 10)
local answer = numberA + numberB
Pretty simple
oh wow. How would I make the parts at the bottom tho. Like the only the correct answer will show
the wrong answers will go away (on the block) (so they fall and die) if this all makes sense yk
if you dont understand how i explained it about the blocks u can watch the vid
you can loop through the floor pieces or a table containing the numbers
example:
local a = 1 + 1 -- 2
for _, piece in floorPieces do
if tonumber(piece.Name) ~= a then -- assuming the pieces are named after the numbers
piece.CanCollide = false -- make it uncollidable
end
end
hmm, ok ill try it out ty yall!
Just name to all the blocks with their respective number.
Then just go through all the blocks under a folder, preferably Blocks
and do a check:
local numberA = math.random(0, 10)
local numberB = math.random(0, 10)
local answer = numberA + numberB
task.wait(ROUND_TIME)
local answer = numberA + numberB
for _, block in Blocks:GetChildren() do
block.CanCollide = (tonumber(block.Name) == answer)
end
do you think you can explain what this line means?
local canCollide = tonumber(block.Name) == answer
canCollide
is a variable. Specifically, it’s a conditional. We know this because of the distinct ==
. It’s checking whether or not tonumber(block.Name)
is equal to answer
. If it is equal to it, then it will return true and canCollide
will be true. If it is not equal, then it will return false and canCollide
will be false.
So, if the number selected and the block’s number are equal, you can collide with it and stand on it. But if not, you can’t.
tonumber()
simply converts something into a number. block.Name
is naturally a string
because it is a name, so we need to convert it into a number to check if it is equal to another number.
It basically outputs true
if the name of the block converted to a number is equal to the answer and false
if otherwise. You can think of it like this, @NotPerplexedlul
if tonumber(block.Name) == answer then
block.CanCollide = true
else
block.CanCollide = false
end
ty ty yall. One last thing tho. How can I make it so the timer work
with everything else. And how do i make it so the blocks say random numbers on the surface GUI
The DevForum is used to help you with making scripts. We will not just give you the whole script.
Try making the script yourself first and then ask us for help if you get stuck.
yeah your right ty for the help
Detailed I suppose?
local FolderOfAllParts = game.Workspace.Tiles -- path to the folder of tiles
while true do -- a loop for rounds
wait(2) -- a sort of intermission
local number1 = math.random(0,10) -- our first number
local number2 = math.random(0,10) -- second number
local answer = number1 + number2 -- the sum
for _,v in pairs(FolderOfAllParts:GetChildren()) do -- loop through all folder assigning them with names
v.Name = math.random(0,10) -- setting their name to be random
end
wait(2) -- another wait
for _,v in pairs(FolderOfAllParts:GetChildren()) do -- another loop so we can make them dissappear
v.CanCollide = v.Name == tostring(answer) -- CanCollide means if the player can touch them and v.Name == tostring(answer) means if the parts name is equal to our answer
v.Transparency = v.Name == tostring(answer) and 0 or 1 -- same as above
end
end
ChatGPT is also a thing nowadays.
Not to be rude and to be also rude is you should start using your own brain and learn scripting first then making such games. I would say use either ChatGPT or use coaching by some professionals or just analyze scripts as LuaU is not at all hard to learn.
Yes, but I wouldn’t advise beginner scripters to use it, as its just spoon-feeding but on steroids.
you should only use chatgpt as a last resort, it is extremely innacurate with roblox-related development topics
I know but I am talking about some small fixes as like you said last resort. When your brain says: Ah #### here we go again. Or when your like OP. (Sorry not to be rude)