Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me?

Asked by 10 years ago

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)

0
Could you please edit this post to correct the formatting of your script? BlueTaslem 18071 — 10y

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
10 years ago

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

m=math.random(1,5)
Ad

Answer this question