if math.random(4) == 1 then
local guy = game.ReplicatedStorage.Thing.Lil_Guy
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("lil guy found")
elseif 2 then
local guy = game.ReplicatedStorage.Thing.nooby
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("noob sleeping")
elseif 3 then
local guy = game.ReplicatedStorage.Thing.Kid
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("Kid in tree")
elseif 4 then
local guy = game.ReplicatedStorage.Thing.Bike
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("left my bike sorry")
end
1 Like
forgot to mention i have two scripts one in the workspace and replicated storage where the items are and when the randomizer script chooses one it clones it and puts it in the workspace folder. the folders are called “Thing”
because it takes the math.random in only 1 argument. You’ll have to do:
local randomNumber = math.random(4)
if randomNumber == 1 then
local guy = game.ReplicatedStorage.Thing.Lil_Guy
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("lil guy found")
elseif randomNumber == 2 then
local guy = game.ReplicatedStorage.Thing.nooby
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("noob sleeping")
elseif randomNumber == 3 then
local guy = game.ReplicatedStorage.Thing.Kid
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("Kid in tree")
elseif randomNumber == 4 then
local guy = game.ReplicatedStorage.Thing.Bike
local clone = guy:Clone()
clone.Parent = workspace.Thing
print("left my bike sorry")
end
any non-zero, non-nill, non-false arugument will always return true, that’s why you’re elseif 2 was always running
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.