Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone help me?

Basically i'm making a quest game on roblox, and for one of the quests you need to go through a maze and find one of 5 randomly spawned keys to open a door. it has several scripts and subscripts, this is the part i'm pretty sure it is messing up on. It's messing up somewhere in the random math section here is the code:

local db = 1 t = script.Timer script.Parent.Touched:connect(function(z) local h = z.Parent:FindFirstChild("Humanoid") if h ~= nil and db == 1 then a = game.Players:findFirstChild(h.Parent.Name) db = 0 local p = game.Players:GetPlayerFromCharacter(z.Parent) local e = t:clone() e.Parent = a.PlayerGui e.Playing.Value = true wait(1) game.Lighting.world1hedge:clone().Parent = game.Workspace m = (math.random(0,5)

if m == 1 then
game.Lighting.world1keys.key:clone().Parent = game.Workspace
wait(script.Parent.Parent.time.Value)
game.Workspace.Key1:Remove()
	end
if m == 2 then
game.Lighting.world1keys.key2:clone().Parent = game.Workspace
wait(script.Parent.Parent.time.Value)
game.Workspace.Key2:Remove()
	end
if m == 3 then
game.Lighting.world1keys.key3:clone().Parent = game.Workspace
wait(script.Parent.Parent.time.Value)
game.Workspace.Key3:Remove()
	end
if m == 4 then
game.Lighting.world1keys.key4:clone().Parent = game.Workspace
wait(script.Parent.Parent.time.Value)
game.Workspace.Key4:Remove()
	end
if m == 5 then
game.Lighting.world1keys.key5:clone().Parent = game.Workspace
wait(script.Parent.Parent.time.Value)
game.Workspace.Key5:Remove()
	end
end
wait(script.Parent.Parent.time.Value)
game.Workspace.World1hedge:Remove()
wait(1)

db = 1 else return end end)

1 comment

0

Could you please edit this post to correct the formatting of your script?

1 answer

Change m=(math.random(0,5) to this:

m=math.random(1,5)

This discussion is preserved as it was. New answers, comments, and votes are closed.