I got this minigame template and out of common sense I was able to start editing and adding maps to make my own minigame series, however when a round is about to end it gets stuck and won't ever finish.
I found this in the output
15:24:47.859 - ServerStorage.Modules.GameHandler:67: attempt to perform arithmetic on local 'points' (a userdata value)
so I went to that line and here's what I found.
module.AwardPlayers = function(val,player)
if player then
local stats = player:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")
points = points + val
else
for i,v in next, players:GetPlayers() do
local stats = v:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")
**points = points + val**
*-- the words in bold were line 67*
end
end
end
So I'm trying to find out what userdata value means and if it has anything to do with "val" on line 67.
I think I'll start by asking, what does val mean in lua?
Is it short for value? I'm not so sure because when I changed val to value I got an error.
Out of all my questions you do not have to answer all of them, just if you have any information let me know.
Thanks!
BY THE WAY... Is there any way to make this post look like a text editor? I preview this and it looks like a bunch of paragraphs out of a book. Extremely confusing for sharing entire scripts. I'm afraid I'll have to re-ask this question because people won't be able to separate the lines of script.
I'll give the whole script.
--Module to handle the current game being played
local module = {}
local msgs = game.ReplicatedStorage.Events:WaitForChild("Messages")
local storage = game.ServerStorage
local games = storage.Games:GetChildren()
local players = game.Players
local chosenGame = nil
module.Round = function(number)
local num,dec = math.modf(number)
if dec >= 0.5 then
return math.ceil(number)
else
return math.floor(number)
end
end
module.IsA = function(name)
for i = 1,6 do
if name == "Window"..i then
return true
end
end
end
module.SetWindows = function(bool)
local lobby = workspace.Lobby
for i,v in next, lobby.Windows:GetChildren() do
if bool then
if not module.IsA(v.Name) then
v.Transparency = 0
v.BrickColor = BrickColor.new("Really black")
v.Reflectance = 0
end
else
v.BrickColor = BrickColor.new("Light blue")
v.Reflectance = 0.3
v.Transparency = 1
end
end
end
module.LoadPlayers = function(player)
if player then
local isPlaying = player:FindFirstChild("IsPlaying")
if isPlaying then
isPlaying:Destroy()
end
player:LoadCharacter()
else
for i,v in next, players:GetPlayers() do
local isPlaying = v:FindFirstChild("IsPlaying")
if isPlaying then
isPlaying:Destroy()
end
v:LoadCharacter()
end
end
end
module.AwardPlayers = function(val,player)
if player then
local stats = player:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")
points = points + val
else
for i,v in next, players:GetPlayers() do
local stats = v:WaitForChild("leaderstats")
local points = stats:WaitForChild("Points")
points = points + val
end
end
end
module.Intermission = function(int)
for i = int,0,-1 do
module.MessageOut("Intermission: "..i)
wait(1)
end
end
module.NewGame = function()
module.MessageOut("Picking a random game...")
wait(2)
module.SelectGame()
wait(2)
module.LoadGame()
wait(2)
end
module.SelectGame = function()
local speed = 0
local num
if game.ServerStorage.Values.Dev.Value then
num = 1
else
num = 40
end
for i = 0,num do
if i > 30 and #games > 1 then
speed = speed + 0.05
end
local ranGame = games[math.random(1,#games)]
while ranGame == chosenGame and #games > 1 do
wait()
ranGame = games[math.random(1,#games)]
end
chosenGame = ranGame
storage.Values.Map.Value = chosenGame.Name
module.MessageOut(chosenGame.Mode.Value)
wait(speed)
end
module.MessageOut("The chosen game is "..chosenGame.Mode.Value.."!")
end
module.LoadGame = function()
local Game = storage.Games[chosenGame.Name]
local total = #Game.Parts:GetChildren()
module.NewHolder(Game)
Game.Handler:Clone().Parent = module.CurrentGame()
Game.Time:Clone().Parent = module.CurrentGame()
if Game:FindFirstChild("Sky") then
Game.Sky:Clone().Parent = game.Lighting
end
for i,v in next, Game.Parts:GetChildren() do
v:Clone().Parent = module.CurrentGame()
module.MessageOut("Loading game: "..(module.Round((i/total)*100)).."%")
wait(0.01)
end
module.MessageOut("Game loaded!")
end
module.StartGame = function()
module.SetPlaying()
game.ServerStorage.Values.Running.Value = true
module.CurrentGame().Handler.Disabled = false
module.SetWindows(true)
end
module.Reset = function()
module.SetWindows(false)
game.ServerStorage.Values.Playing.Value = 0
module.CurrentGame():Destroy()
workspace.BasePlate:Destroy()
game.ServerStorage.BasePlate:Clone().Parent = workspace
game.Lighting:ClearAllChildren()
for i,v in next, players:GetPlayers() do
local isPlaying = v:FindFirstChild("IsPlaying")
if isPlaying and isPlaying.Value then
module.LoadPlayers(v)
end
end
end
module.GameTimer = function(timer)
for i = timer,0,-1 do
module.MessageOut(i)
wait(1)
end
end
module.CurrentGame = function()
return workspace[chosenGame.Name]
end
module.NewHolder = function(game)
local model = Instance.new("Model",workspace)
model.Name = game.Name
end
module.TeleportPlayers = function(location,player)
if player then
if player.Character:WaitForChild("Humanoid").Health ~= 0 then
player.Character:MoveTo(location.Position + Vector3.new(0,1,0))
end
else
for i,v in next, game.Players:GetPlayers() do
--v.Character:MoveTo(location + Vector3.new(0,1,0))
if v.Character:WaitForChild("Humanoid").Health ~= 0 then
v.Character:MoveTo(Vector3.new(location.Position.X + math.sin(i),1,location.Position.Z + math.cos(i)))
wait(0.1)
v.Character.Torso.Anchored = true
end
end
end
end
module.SetPlaying = function()
local playing = game.ServerStorage.Values.Playing
for i,v in next, players:GetPlayers() do
if v.Character:WaitForChild("Humanoid").Health ~= 0 then
local isPlaying = Instance.new("BoolValue",v)
isPlaying.Name = "IsPlaying"
isPlaying.Value = true
playing.Value = playing.Value + 1
end
end
end
module.SetTools = function(tools,player)
if player then
for i,v in next, tools do
v:Clone().Parent = player.Backpack
end
else
for i,p in next, players:GetPlayers() do
local isPlaying = p:FindFirstChild("IsPlaying")
if isPlaying and isPlaying.Value then
for i,v in next, tools do
v:Clone().Parent = p.Backpack
end
end
end
end
end
module.Equip = function(tool,player)
if player then
local char = player.Character
local human = char:WaitForChild("Humanoid")
human:EquipTool(tool)
else
for i,v in next, players:GetPlayers() do
local isPlaying = v:FindFirstChild("IsPlaying")
if isPlaying and isPlaying.Value then
local char = v.Character
local human = v:WaitForChild("Humanoid")
human:EquipTool(tool)
end
end
end
end
module.MessageOut = function(msg,player,bool)
if player then
msgs:FireClient(player,msg,bool)
else
msgs:FireAllClients(msg,bool)
end
end
module.Countdown = function(num)
if game.ServerStorage.Values.Dev.Value then
num = 1
end
for i = num,0,-1 do
module.MessageOut("Game beggining in "..i)
wait(1)
end
end
return module

3 comments
format your code
You should make this into a code block. Edit this and press "code block." Then put this into code block. That should work.
You should make this into a code block. Edit this and press "code block." Then put this into code block. That should work.