I am trying make a command to give someone magic however it is returning this error:
Here is my script:
--[[
SERVER PLUGINS' NAMES MUST START WITH "Server: "
CLIENT PLUGINS' NAMES MUST START WITH "Client: "
Plugins have full access to the server/client tables and most variables.
You can use the MakePluginEvent to use the script instead of setting up an event.
PlayerChatted will get chats from the custom chat and nil players.
PlayerJoined will fire after the player finishes initial loading
CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
service.HookEvent('PlayerChatted',function(msg,plr)
print(msg..' from '..plr.Name..' Example Plugin')
end)
service.HookEvent('PlayerJoined',function(p)
print(p.Name..' Joined! Example Plugin')
end)
service.HookEvent('CharacterAdded',function(plr)
server.RunCommand('name',plr.Name,'BobTest Example Plugin')
end)
--]]
server = nil -- Mutes warnings about unknown globals
service = nil
return function()
server.Commands.givemagic = {
Prefix = server.Settings.Prefix; -- Prefix to use for command
Commands = {"givemagic"}; -- Commands
Args = {"player","amount"}; -- Command arguments
Description = "Gives a certain player an amount of magic. They must be a witch, if the amount you attempt to give them is more than their max, it will up their max."; -- Command Description
Hidden = false; -- Is it hidden from the command list?
Fun = false; -- Is it fun?
AdminLevel = "Admins"; -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
Function = function(plr,args) -- Function to run for command
print(args[1])
print(args[2])
local TargetPlayer = game.Players:FindFirstChild(args[1])
local Magic = tonumber(TargetPlayer.Character.WitchStats.Magic.Value)
local MaxMagic = tonumber(TargetPlayer.Character.WitchStats.MaxMagic.Value)
print(MaxMagic)
if args[2] > MaxMagic then
MaxMagic = args[2]
Magic = args[2]
elseif args[2] < MaxMagic then
local function testIfToMuch(Player,Adding)
local currentMagic = tonumber(Player.WitchStats.Magic.Value)
local maxMagic = tonumber(Player.WitchStats.MaxMagic.Value)
local addedAmount = currentMagic + Adding
if addedAmount > MaxMagic then
return "more"
elseif addedAmount < MaxMagic then
return "less"
elseif addedAmount == MaxMagic then
return "equal"
end
end
local test = testIfToMuch(TargetPlayer,args[2])
if test == "more" then
MaxMagic = Magic + args[2]
Magic = args[2]
elseif test == "less" then
Magic = Magic + args[2]
elseif test == "equal" then
Magic = Magic + args[2]
end
end
end
}
end
Line 44 is
if args[2] > MaxMagic then
All help is appreciated!