generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

@DR10D

Previous Thread :: Next Thread 
xShenanigans is not online. xShenanigans
Joined: 23 Jul 2012
Total Posts: 209
28 Jul 2012 02:44 PM
Why in heavens sake don't you make games? You seems to know plenty, and be on RBLX plenty to do so. And then check on the forums every 15 minutes to help people. I would love to play your games :>
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
28 Jul 2012 02:47 PM
Because I don't have any ideas for games, and if I did I'd try to make them in Java (though I am learning C#+XNA and C++ too).
Though atm I am working on a minigame thing, nearly got 1 game working, just need to make the players reset, and then make more games and actually build the place.

for _, g in pairs(workspace.AllGames:GetChildren()) do
if (g:findFirstChild("SpawnPlayers")) then
local s = g.SpawnPlayers;
s.BrickColor = BrickColor.new("Black");
s.Transparency = 1;
end
end
local clearOutputBeforeRunning = true;
local isDebugMode = true; -- When true, doesn't check for amount of planes
local timeBetweenGames = (isDebugMode) and 2 or 5;
local isPlayingGame = false;
local minigames = {
-- {Game name (no spaces), Game name, Intro text, Game cloned from workspace}
{"DisappearingPlatforms", "Disappearing Platforms", "Survive for as long as you can whilst the platforms disappear!", workspace.AllGames.DisappearingPlatforms:Clone()}
};
local currentGame = { };
local currentGameMod = workspace.CurrentMinigame;
local gameMod = nil;
local minigameMessage = Instance.new("Message", workspace); minigameMessage.Name = "MinigameMessage";

-- Displays a message with text, in parent and lasts for time
function message(text, time, par)
text = text or "Error giving message: text = nil";
time = time or 5;
par = par or workspace;
print(text);
if (par == workspace) then
minigameMessage.Text = text;
wait(time);
minigameMessage.Text = "";
else
local msg = Instance.new("Message", par);
msg.Name = "MinigameMessage";
msg.Text = text;
wait(time);
msg:Destroy();
end
end

-- Calls the message function with error text
function reportError(text)
text = text or "(No error message given)";
message("ERROR: \""..text.."\" - Report this to dr01d3k4", 10, workspace);
end

-- Picks a random minigame from the table minigames. Might add a parameter to skip random and go for an admin selected one
function pickMinigame()
return minigames[math.random(1, #minigames)];
end

-- Picks and loads the next minigame, teleports all players to it
-- Returns false if there was an error
function startAGame()
message("Picking the next game...");
local newGameTable = pickMinigame();
local miniMod = newGameTable[4]; -- game.Lighting.AllGames:findFirstChild(newGameTable[1]);
if (miniMod == nil) then
reportError(newGameTable[1].." does not exist");
return false;
end
wait(1);
message("The next game will be "..newGameTable[2].."!");
currentGame = newGameTable;
gameMod = miniMod:Clone();
gameMod.Parent = currentGameMod;

wait(1);
local spawnPlayers = gameMod:findFirstChild("SpawnPlayers");
if (spawnPlayers == nil) then
reportError("SpawnPlayers does not exist in minigame "..newGameTable[1]);
return false;
end
delay(0, function () message(newGameTable[3]); end);
for _, plr in pairs(getPlayersToPlay()) do
if (plr.Character) then
plr.IsInGame.Value = true;
plr.Character.Torso.CFrame = CFrame.new(genRandomPos(spawnPlayers.Position, spawnPlayers.Size));
wait(0.1);
plr.Character.Torso.Anchored = true;
end
end
repeat wait(0.1); until (workspace.MinigameMessage.Text == "");
for _, plr in pairs(getPlayersToPlay()) do
if (plr.Character) then
plr.Character.Torso.CFrame = CFrame.new(genRandomPos(spawnPlayers.Position, spawnPlayers.Size));
wait(0.1);
plr.Character.Torso.Anchored = false;
end
end

isPlayingGame = true;
return true;
end

function playGame()
if (currentGame[1] == "DisappearingPlatforms") then -- Each game plays differently
while ((#gameMod.Platforms:GetChildren() > 1) and (#getPlayersInGame() ~= 0)) do
wait(3);
local plats = gameMod.Platforms:GetChildren()
print("Platforms remaining: "..#plats.."; Players remaining: "..#getPlayersInGame());
local nextPlat = plats[math.random(1, #plats)];
nextPlat.BrickColor = BrickColor.new("Black");
wait(0.2);
for i = 0, 1, 0.1 do
nextPlat.Transparency = i;
wait(0.15);
end
nextPlat:Destroy();
end
print("Game over!");
if (#getPlayersInGame() == 0) then
print("All players are dead");
elseif (#gameMod.Platforms:GetChildren() == 1) then
print("Only 1 platform remaining");
else
print("Don't know why game ended O.o");
end
winGame();
end
end

function winGame()
print("Winning game");
local winners = getPlayersInGame();
if (#winners == 0) then
message("Nobody won the game!");
return;
elseif (#winners == 1) then
message(winners[1].Name.." has won!");
elseif (#winners == 2) then
message(winners[1].Name.." and "..winners[2].Name.." have won!");
else
message("There were multiple winners!");
end
for _, p in pairs(winners) do
p.leaderstats.Won.Value = p.leaderstats.Won.Value + 1;
p.leaderstats.Total.Value = p.leaderstats.Total.Value + 1;
end
end

-- Clears up everything and resets the values;
function resetGame()
currentGame = { };
isPlayingGame = false;
if (gameMod ~= nil) then gameMod:Destroy(); end
currentGameMod:ClearAllChildren();
for _, p in pairs(game.Players:GetChilren()) do
p.IsInGame.Value = false;
end
end

-- For now just gets every player. Will eventually add an AFK system so only teleports you if you are playin
function getPlayersToPlay()
return game.Players:GetChildren();
end

function getPlayersInGame()
local plrs = { };
for _, p in pairs(game.Players:GetChildren()) do
if (p.IsInGame.Value) then
plrs[#plrs + 1] = p;
end
end
return plrs;
end

-- Generates a random position for a player to spawn based on position p and size s of part SpawnPlayers
function genRandomPos(p, s)
local x = p.x + math.random(0, s.x) - (s.x / 2);
local z = p.z + math.random(0, s.z) - (s.z / 2);
return Vector3.new(x, p.y, z);
end

-- Checks whether the amount of players in the game is bigger-than-or-equal-to 2
-- Always returns true in debug mode to allow games to work with only 1 or no players
function hasEnoughPlayers()
return (game.Players.NumPlayers >= 2) or (isDebugMode);
end

game.Players.ChildAdded:connect(function (newPlayer)
local leaderstats = script.leaderstats:Clone();
leaderstats.Parent = newPlayer;
local isInGame = Instance.new("BoolValue", newPlayer);
isInGame.Name = "IsInGame";
isInGame.Value = false;

newPlayer.CharacterAdded:connect(function (char)
char.Humanoid.Died:connect(function () isInGame.Value = false; end);
end);
end);

if (clearOutputBeforeRunning) then
for a = 1, 250 do
print();
end
end
wait(1);
workspace.AllGames:Destroy();

-- This runs when server starts. Checks enough players, then starts game, or waits another 5 seconds
-- At end of a minigame, the stack clears and it returns back to this while loop
while wait(timeBetweenGames) do
if (hasEnoughPlayers()) then
if (startAGame()) then
playGame();
end
resetGame();
if (isDebugMode) then wait(5); end
else
message("2 or more players are required to play!");
end
end
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
28 Jul 2012 02:48 PM
Why does that seem so much [Content Deleted] similar to what I am typing right now?

Time to update this siggy, to this: !
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
28 Jul 2012 02:49 PM
Wut?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image