So I created a script that was intended to create a part based on whichever random number is picked from math.random. There are no errors from Output.
The problem is that there are not any new parts created when I join the game (through the Roblox Player and through Studio (I'm new to this part of scripting so I don't know if you're character loads before the scripts as if it was single player mode).
Here's the script I have, thanks for any possible help.
Players = game:GetService("Players") MyPart1 = Instance.new("Part", workspace) MyPart2 = Instance.new("Part", workspace) MyPart3 = Instance.new("Part", workspace) function PlayerJoin(Player) math.random(1,3) if math.random == 1 then print(Player.Name .. "has entered the game") print (MyPart1) MyPart1.Name = "Example 1" MyPart1.BrickColor = BrickColor.new("Bright blue") MyPart1.Position = Vector3.new(100,100,100) MyPart1.Size = Vector3.new(30,30,30) end if math.random == 2 then print(Player.Name .. "got TKO'd by JOHN CENA!!!") print (MyPart2) MyPart2.Name = "Example 2" MyPart2.BrickColor = BrickColor.new("Bright blue") MyPart2.Position = Vector3.new(200,200,200) MyPart2.Size = Vector3.new(50,50,50) end if math.random == 3 then print(Player.Name .. "is in the WWE Superslam!!!") print (MyPart3) MyPart3.Name = "Example 3" MyPart3.BrickColor = BrickColor.new("Sea green") MyPart3.Position = Vector3.new(300,300,300) MyPart3.Size = Vector3.new(70,70,70) end end Players.PlayerAdded:connect(PlayerJoin)
No case is running, because you aren't calling math.random
. You're comparing the function with the numbers, which is always false.
This should fix it:
Players = game:GetService("Players") MyPart1 = Instance.new("Part", workspace) MyPart2 = Instance.new("Part", workspace) MyPart3 = Instance.new("Part", workspace) function PlayerJoin(Player) local x = math.random(1,3) if x == 1 then print(Player.Name .. "has entered the game") print (MyPart1) MyPart1.Name = "Example 1" MyPart1.BrickColor = BrickColor.new("Bright blue") MyPart1.Position = Vector3.new(100,100,100) MyPart1.Size = Vector3.new(30,30,30) end if x) == 2 then print(Player.Name .. "got TKO'd by JOHN CENA!!!") print (MyPart2) MyPart2.Name = "Example 2" MyPart2.BrickColor = BrickColor.new("Bright blue") MyPart2.Position = Vector3.new(200,200,200) MyPart2.Size = Vector3.new(50,50,50) end if x == 3 then print(Player.Name .. "is in the WWE Superslam!!!") print (MyPart3) MyPart3.Name = "Example 3" MyPart3.BrickColor = BrickColor.new("Sea green") MyPart3.Position = Vector3.new(300,300,300) MyPart3.Size = Vector3.new(70,70,70) end end Players.PlayerAdded:connect(PlayerJoin)
EDIT: derp, math.random.