|
| 27 Nov 2012 10:56 PM |
So lets take a hunger games place for example.
When the game starts, weapons and tools are generated RANDOMLY around the cornucopia.
How can I get to, In a script, to spawn weapons randomly around the selected object.
Im also looking on how to spawn weapons from free models to (Yes Im a FM Suck it) |
|
|
| Report Abuse |
|
| |
|
| 27 Nov 2012 11:00 PM |
| Yes, I understand that part, but Im just having trouble what to put in there, Do I just put the NAME of a weapon or something. |
|
|
| Report Abuse |
|
| |
|
| 27 Nov 2012 11:06 PM |
Heres the script im looking at.
local Cannon = Instance.new("Sound", game.Workspace) Cannon.SoundId = "http://www.roblox.com/asset/?id=2920959" Cannon.Volume,Cannon.Pitch = 1,.1 Cannon.Name = "CannonSound" local BEGIN = Instance.new("Sound", game.Workspace) BEGIN.Name = "TestSound" BEGIN.SoundId = "http://www.roblox.com/asset/?id=19344667" BEGIN.Pitch = .07 BEGIN.Volume = 2 local Map shared.Tributes = {} shared.PreviousVictor = "Player" local Requiration = 2 local Spawn_Radius = 80 local Year = 0 local NextDistrict = 1 local ND = 1 local WhoD = {} local Spawns = {} local BoxSpawn = {} local MapS local Tick = Instance.new("Sound", game.Workspace) Tick.SoundId = "http://roblox.com/asset/?id=10209668" --rbxasset://sounds\\clickfast.wav Tick.Pitch = 4 local Boom = Instance.new("Sound", game.Workspace) Boom.SoundId = "http://www.roblox.com/asset/?id=11984254" Boom.Pitch = 1.7 Boom.Volume = 2 local GameMusic = Instance.new("Sound", game.Workspace) GameMusic.Volume = 2 GameMusic.Pitch = 1.6 GameMusic.SoundId = "http://www.roblox.com/asset/?id=27697743" GameMusic.Looped = true local Districts = { "http://www.roblox.com/asset/?id=77819652"; "http://www.roblox.com/asset/?id=77819693"; "http://www.roblox.com/asset/?id=77819723"; "http://www.roblox.com/asset/?id=78661527"; "http://www.roblox.com/asset/?id=78661551"; "http://www.roblox.com/asset/?id=78661565"; "http://www.roblox.com/asset/?id=78661585"; "http://www.roblox.com/asset/?id=78661599"; "http://www.roblox.com/asset/?id=78661612"; "http://www.roblox.com/asset/?id=78661628"; "http://www.roblox.com/asset/?id=78661649"; "http://www.roblox.com/asset/?id=78661661"; }
function addMessage(text, time) game.Workspace.AddMessage.Value = tostring(text) Tick:Play() wait(time) end function resetGame() MapS = game.Workspace:findFirstChild("MapStuff") game.Lighting.FogEnd = 50000 if game.Lighting:findFirstChild("Sky") then game.Lighting.Sky:Remove() end for Q,W in pairs(game.Workspace:GetChildren()) do if W:IsA("Tool") or W.Name == "FIREMODEL" then W:Remove() end end for C,D in pairs(game.Players:GetChildren()) do if D.Character and D:findFirstChild("InArena") then D.Character:BreakJoints() D.InArena.Value = false D.InArena2.Value = false end end shared.Tributes = {} NextDistrict = 1 ND = 1 game.Lighting.TimeOfDay = 14 for G,H in pairs(game.Workspace.Map:GetChildren()) do H:Remove() if math.random(1,13) == 1 then wait() end end game.Workspace.Map:Remove() for A,B in pairs(game.Players:GetChildren()) do if B:findFirstChild("District") then B.District.Value = 0 end B.CameraMode = "Classic" B.InArena2.Value = false end MapS:Remove() Begin() end function countDown() game.Workspace.Countdowning.Value = true game.Workspace.SpawnTools.Disabled = false for K,L in pairs(shared.Tributes) do if L:findFirstChild("Hunger") and L:findFirstChild("Thirst") then L.Hunger.Value = 100 L.Thirst.Value = 100 if L.Character:findFirstChild("Humanoid") then L.Character.Humanoid.Health = L.Character.Humanoid.MaxHealth end end end for Y,Q in pairs(shared.Tributes) do if Q.Character:findFirstChild("Humanoid") then Q.Character.Humanoid.WalkSpeed = 12 end if Q.Character:findFirstChild("Torso") then if Q.Character.Torso.roblox.Texture == "http://www.roblox.com/asset/?id=84489528" or Q.Character.Torso.roblox.Texture == "http://www.roblox.com/asset/?id=85190593" then game.Lighting.All.Bottle:Clone().Parent = Q.Backpack end end end Time = 60 for i = 1, Time do game.Workspace.CountdownMessage.Value = Time-i.." | DO NOT STEP OFF PEDASTLE EARLY" Boom:Play() wait(.6) end game.Workspace.Countdowning.Value = false BEGIN:Play() game.Workspace.CountdownMessage.Value = "" for B,C in pairs(shared.Tributes) do C.Character.Humanoid.WalkSpeed = 24 if C.Character:findFirstChild("Torso") then if C.Character.Torso.roblox.Texture == "http://www.roblox.com/asset/?id=84489528" or C.Character.Torso.roblox.Texture == "http://www.roblox.com/asset/?id=85190593" then C.Character.Humanoid.WalkSpeed = 26 end end end addMessage("Begin!",0) GameMusic:Play() while #shared.Tributes >= 2 do wait(2) end GameMusic:Stop() Winner = (#shared.Tributes >= 1 and shared.Tributes[1] or game.Players:GetChildren()[1]) if Winner.InArena.Value == true then Winner.InArena.Value = false Winner.Cash.Value = Winner.Cash.Value + 250 addMessage("The winner of the "..(Year >= 4 and Year.."th" or Year).." hunger games is "..Winner.Name, 4) shared.PreviousVictor = Winner.Name Winner.InArena2.Value = false for i = 1, 50 do Winner.Exp.Value = Winner.Exp.Value + 1 wait() end Winner.Character:BreakJoints() else addMessage("Nobody won this hunger games", 4) end resetGame() end local TRIBS = {} local FAKETABLE = {} function GetTributes() FAKETABLE = {} for _,v in pairs(game.Players:GetChildren()) do if v:findFirstChild("InArena") then if v.TimeInGame.Value >= 60 then if v.InArena.Value and v.Character.Humanoid.Health >= 1 then table.insert(FAKETABLE, v) else v.InArena.Value = false end end end end TRIBS = FAKETABLE return TRIBS end function SetMap() Map = game.Lighting.Maps:GetChildren()[math.random(1,#game.Lighting.Maps:GetChildren())]:Clone() Map.Parent = game.Workspace wait(1) local Amount = #GetTributes() local steps = Amount MapS = game.Workspace.MapStuff Spawn_Radius = 110 center = MapS.Base.Part.Position Spawns = {} for i = 1, Amount do P = game.Lighting.Pad:Clone() P.Parent = MapS.Spawns wait() P.Part.CFrame = CFrame.new(center.x+math.sin(math.rad(360/steps*i))*Spawn_Radius,center.y,center.z+math.cos(math.rad(360/steps*i))*Spawn_Radius)*CFrame.fromEulerAnglesXYZ(0,math.rad(360/steps*i)+math.rad(360),0) P.Top.Position = P.Part.Position + Vector3.new(0,0.1,0) table.insert(Spawns, P) end addMessage("Please wait, loading map", 5) wait(17) game.Workspace.Countdowning.Value = true game.Workspace.CountdownMessage.Value = "60 | REMAIN STANDING ON PAD OR EXPLODE FROM GAMEMAKER ACTIONS" for B,C in pairs(GetTributes()) do M = Instance.new("Model", C.Character) FH = C.Character.Head:Clone() FH.Parent = M H = Instance.new("Humanoid", M) H.Health = 0 H.MaxHealth = 0 FH.Name = "Head" M.Name = C.Character.Name C.Character.Head.Transparency = 1 weld = Instance.new("Weld") weld.Parent = C.Character.Head weld.Part0 = C.Character.Head weld.Part1 = FH D = math.random(1,#Spawns) C.InArena2.Value = true --[[CRW = script.Watch:Clone() CRW.Parent = C.PlayerGui CRW.Disabled = false]] C.Character.Torso.CFrame = Spawns[D].Top.CFrame + Vector3.new(0,2.5,0) table.remove(Spawns,D) end countDown() end function getThoseWithDistrict(Dist) WhoD = {} for A,B in pairs(game.Players:GetChildren()) do if B:findFirstChild("District") then if B.District.Value == Dist and B.Character.Humanoid.Health >= 1 then table.insert(WhoD, B.Name) end end end return WhoD end function partReap() for E,F in pairs(GetTributes()) do if not F:findFirstChild("District") then table.remove(shared.Tributes,E) end end wait() E = {} for A,B in pairs(GetTributes()) do table.insert(E,B) end wait() for G,H in pairs(E) do if H:findFirstChild("District") then H.District.Value = NextDistrict H.InArena.Value = true ND = ND + 1 if ND >= 3 then ND = 1 NextDistrict = NextDistrict + 1 end end end for i = 1, math.ceil(#GetTributes()/2) do addMessage("District "..i.." \n "..table.concat(getThoseWithDistrict(i), " & "), 1.7) end SetMap() end function reapTributes() for A,B in pairs(game.Players:GetChildren()) do if B.Character:findFirstChild("Humanoid") then if B:findFirstChild("InArena") and B:findFirstChild("Cash") then if B.Character.Humanoid.Health >= 1 then if B.TimeInGame.Value >= 60 then B.InArena.Value = true DS = script.Death:Clone() DS.Parent = B.PlayerGui DS.Disabled = false B.Cash.Value = B.Cash.Value + 100 end end end end end wait(.1) if #GetTributes() >= 25 then for C = 1, #GetTributes() - 24 do D = math.random(1,#GetTributes()) GetTributes()[D].InArena.Value = false table.remove(shared.Tributes,D) if GetTributes()[D].Character:findFirstChild("Torso") then if GetTributes()[D].Character.Torso:findFirstChild("Death") then GetTributes()[D].Character.Torso.Death:Remove() end end end end partReap() end local ELI local FAKEELI function getEligible() ELI,FAKEELI = {},{} for A,B in pairs(game.Players:GetChildren()) do if B:findFirstChild("InArena") then if B.TimeInGame.Value >= 10 then table.insert(FAKEELI, B) end end end ELI = FAKEELI return ELI end function Begin() wait(4) addMessage("",0) if not game.CreatorId == 26061794 and not game.PlaceId == 0 then M = Instance.new("Message", game.Workspace) M.Text = "Copied Game! This is by Terratronic!" script:Remove() end if #getEligible() >= Requiration then Year = Year + 1 addMessage("May the odds be ever in your favor!",0) ToSay = Year if Year == 1 then ToSay = "1st" end if Year == 2 then ToSay = "2nd" end if Year == 3 then ToSay = "3rd" end addMessage("The "..(ToSay == Year and Year.."th" or ToSay).." annual Hunger Games will now begin!", 3) addMessage((game.Players.NumPlayers >= 25 and 24 or game.Players.NumPlayers).." tributes this year!", 2) reapTributes() else addMessage(Requiration.." people needed for the games.", 1) Begin() end end delay(0, function() while true do shared.Tributes = GetTributes() wait() end end) for i = 1, 100 do addMessage("Game Loading: %"..i, math.random(10,150)/100) end Begin() |
|
|
| Report Abuse |
|
| |
zinc707
|
  |
| Joined: 16 Dec 2008 |
| Total Posts: 2961 |
|
| |
| |
abaw7
|
  |
| Joined: 23 Oct 2009 |
| Total Posts: 745 |
|
|
| 01 Dec 2012 12:59 PM |
math.random(1, #table)
That's your core thing if you want it to be generated randomly |
|
|
| Report Abuse |
|