Ok, so I had this code which worked fine yesterday it is very long tho, so I will give the entire code and where the error is. If you know why and how to fix it, a answer would be much appriciated! Heres the entire code:

local function WaitForChild(parent,name)
	return parent:WaitForChild(name) 
end
local function GetService(name)
	return game:GetService(name)
end
local function IsMonster(v)
	return MonsterPlayer == v
end
local function Save(datastore,key,value)
	local suc,err = pcall(function()
		datastore:SetAsync(key,value)
		print()
	end)
	if not suc then error(err) end
end
local function Load(datastore,key)
	local DATA
	local suc,err = pcall(function()
		DATA = datastore:GetAsync(key)
	end)
	if not suc then error(err) return false end
	if suc then return DATA end
end
local ReplicatedStorage = GetService("ReplicatedStorage")
local ServerStorage = GetService("ServerStorage")
local Players = GetService("Players")
local remoteFunction = WaitForChild(ReplicatedStorage,"nobIm")
local remoteEvent = WaitForChild(ReplicatedStorage,"Imnob")
local timesFired = 0
local timeLeft = 4
local map = nil

Debris = game:GetService("Debris")
DataStore = game:GetService("DataStoreService")
DataStoreUiDesignStore = DataStore:GetDataStore("UiStore2")
DataStoreStatsStore = DataStore:GetDataStore("StatsStore")

Maps = WaitForChild(ServerStorage,"Maps")
MapsChildren = Maps:GetChildren()

OnCoolDownDamage = {}
Votes = {
	["Demo Arena"] = {
		["PlayersVoted"] = {},
		["Votes"] = 0	
	},
}

Attacks = {
	["UndyneSpear"] = WaitForChild(ServerStorage,"Spear"),	
}

AttackTypeInformation = {
	["UndyneSpear"] = {
		[2] = {
			["Damage"] = 4,
			["Cooldown"] = 1.9	
		}	
	}	
}

UndyneCoolDown = {
	[2] = {}
}
InDown = false
MonsterPlayer = nil
Stage = 1
RoundStatus = (Stage == 1 and "Intermission") or (Stage == 2 and "In Game") or (Stage == 3 and "Voting")
Values = {
	["Dust"] = {"NumberValue",0},
	["Love"] = {"NumberValue",1},
	["EXP"] = {"NumberValue",0},
	["MaxEXP"] = {"NumberValue",10},
}
Players.PlayerAdded:Connect(function(player)
	remoteFunction:InvokeClient(player,"LoadUIValues",Load(DataStoreUiDesignStore,"UiFor: "..player.UserId))
	
	local l = Instance.new("Folder");l.Parent = player;l.Name = "leaderstats"
	for i,v in pairs(Values) do
		local l2 = Instance.new(v[1]);l2.Name = i;
		if i == "MaxEXP" then
			l2.Parent = player
		else
			l2.Parent = l
		end;
		l2.Value = Load(DataStoreStatsStore,"Stats: "..player.UserId)[i] or v[2]
		
	end
	local maxExp = player:WaitForChild("MaxEXP")
	local Exp = l:WaitForChild("EXP")
	local Love = l:WaitForChild("Love")
	
	local UPDATE_LEVEL = coroutine.wrap(function()
		while wait() do
			if Exp.Value >= maxExp.Value then
				Love.Value = Love.Value + 1
				Exp.Value = Exp.Value - maxExp.Value
				maxExp.Value = math.ceil(Love.Value*3.5)*(Love.Value*2)
			end
		end
	end)
	UPDATE_LEVEL()
end)

Players.PlayerRemoving:Connect(function(player)
	local Stats = {
		["MaxEXP"] = player:WaitForChild("MaxEXP").Value,
		["EXP"] = player:WaitForChild("leaderstats"):WaitForChild("EXP").Value,
		["Love"] = player:WaitForChild("leaderstats"):WaitForChild("Love").Value,
		["Dust"] = player:WaitForChild("leaderstats"):WaitForChild("Dust").Value,
	}
	Save(DataStoreStatsStore,"Stats: "..player.UserId,Stats)
end)
game:BindToClose(function()
	for i,player in pairs(Players:GetPlayers()) do
		local Stats = {
			["MaxEXP"] = player:WaitForChild("MaxEXP").Value,
			["EXP"] = player:WaitForChild("leaderstats"):WaitForChild("EXP").Value,
			["Love"] = player:WaitForChild("leaderstats"):WaitForChild("Love").Value,
			["Dust"] = player:WaitForChild("leaderstats"):WaitForChild("Dust").Value,
		}
		Save(DataStoreStatsStore,"Stats: "..player.UserId,Stats)
	end
end)
remoteEvent.OnServerEvent:Connect(function(player,...)
	local argumentTable = {...}
	if argumentTable[1] == "UndyneSpear" then
		local IsCFrame,IsVector3 = false,false
		if typeof(argumentTable[2]) == "CFrame" then
			IsCFrame = true
		elseif typeof(argumentTable[2]) == "Vector3" then
			IsVector3 = true
		end
		
		if IsCFrame or IsVector3 then
			
			if AttackTypeInformation["UndyneSpear"][argumentTable[3]] then
				
				
				local Info = AttackTypeInformation["UndyneSpear"][argumentTable[3]];
				local Damage = Info["Damage"]
				local CoolDown = Info["Cooldown"]
				if Info and Damage and CoolDown then
					
					if timesFired >= 8 then
						timesFired = 0;
						UndyneCoolDown[argumentTable[3]][player.Name] = true
						local stop = coroutine.wrap(function()
							print(CoolDown)
							wait(CoolDown)
							print(UndyneCoolDown[argumentTable[3]][player.Name])
							UndyneCoolDown[argumentTable[3]][player.Name] = nil
						end)
						stop()
					end
					print(UndyneCoolDown[argumentTable[3]][player.Name])
					if UndyneCoolDown[argumentTable[3]] and UndyneCoolDown[argumentTable[3]][player.Name] == true then return end 
					timesFired = timesFired + 1
					
					if InDown then return end
					
					local atk = Attacks["UndyneSpear"]:Clone()
					atk.Parent = workspace
					if IsCFrame then
						
						atk.CFrame = argumentTable[2]
						atk.CFrame = CFrame.new(atk.Position,argumentTable[4])
						atk.Anchored = false
						atk.CanCollide = false
						local BodyV = Instance.new("BodyVelocity")
						BodyV.Velocity = atk.CFrame.LookVector*50
						BodyV.Parent = atk
						atk.Touched:connect(function(hit)
							
							local IsCharacter = (hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.Parent) or nil
							if IsCharacter then
								local IsPlayer = Players:GetPlayerFromCharacter(IsCharacter)
								
								if IsPlayer and not (OnCoolDownDamage[IsPlayer.Name] == true) and (IsPlayer == player) then
									IsCharacter:FindFirstChildWhichIsA("Humanoid"):TakeDamage(Damage)
									OnCoolDownDamage[IsPlayer.Name] = true
									wait(2)
									OnCoolDownDamage[IsPlayer.Name] = false
								end
							end
						end)
						Debris:AddItem(atk,5)
						--atk.Anchored = true
					elseif IsVector3 then
						atk.Position = argumentTable[2]
					end
					
				end
			end
		end
	end
end)
remoteFunction.OnServerInvoke = function(player,...)
	local argumentTable = {...}
	
	if argumentTable[1] == "GetRoundStartSeconds" then
		return timeLeft
	elseif argumentTable[1] == "GetRoundStatus" then
		return RoundStatus 
	elseif argumentTable[1] == "Vote" then
		if argumentTable[2] and Votes[argumentTable[2]] and not Votes[argumentTable[2]]["PlayersVoted"][player.Name] then
			
			--Search to find any other ones he voted for
			for i,v in pairs(Votes) do
				if v["PlayersVoted"][player.Name] then
					v["PlayersVoted"][player.Name] = false
					v["Votes"] = v["Votes"] - 1
					
					
				end
			end	
			
			Votes[argumentTable[2]]["PlayersVoted"][player.Name] = true
			Votes[argumentTable[2]]["Votes"] = Votes[argumentTable[2]]["Votes"] + 1
			return Votes
	elseif argumentTable[1] == "SaveUiDesign" then
		Save(DataStoreUiDesignStore,"UiFor: "..player.UserId,argumentTable[2])
	elseif argumentTable[1] == "ReturnDustValue" then
		return player:WaitForChild("leaderstats"):WaitForChild("Dust").Value
	elseif argumentTable[1] == "ReturnExpValue" then
		return player:WaitForChild("leaderstats"):WaitForChild("EXP").Value
	elseif argumentTable[1] == "ReturnMaxExpValue" then
		return player.MaxEXP.Value
	elseif argumentTable[1] == "GetMaps" then
		local ab = {}
		for i,v in pairs(MapsChildren) do
			ab[#ab+1] = v.Name
		end
		return ab
	end
end
end
DecreaseTime = coroutine.wrap(function()
	while wait(1) do
		if timeLeft <= 0 then 
			if Stage == 1 then 
				Stage = 2; 
				timeLeft = 4;
			elseif Stage == 2 then
				Stage = 3;
				timeLeft = 100;
			elseif Stage == 3 then
				Stage = 1;
				timeLeft = 2
			end
			RoundStatus = (Stage == 1 and "Intermission") or (Stage == 2 and "In Game") or (Stage == 3 and "Voting")
		end
		timeLeft = timeLeft - 1
	end
end)

TeleportPlayers = coroutine.wrap(function()
	for i,v in pairs(GetService("Players"):GetPlayers()) do
		if v.Character then
			local a = Instance.new("BoolValue")
			a.Parent = v.Character
			a.Name = "IsMonster"
			a.Value = IsMonster(v)
			
		end
	end
end)

DecreaseTime()

and heres the place Im having troubles:

remoteFunction.OnServerInvoke = function(player,...)
	local argumentTable = {...}
	
	if argumentTable[1] == "GetRoundStartSeconds" then
		return timeLeft
	elseif argumentTable[1] == "GetRoundStatus" then
		return RoundStatus 
	elseif argumentTable[1] == "Vote" then
		if argumentTable[2] and Votes[argumentTable[2]] and not Votes[argumentTable[2]]["PlayersVoted"][player.Name] then
			
			--Search to find any other ones he voted for
			for i,v in pairs(Votes) do
				if v["PlayersVoted"][player.Name] then
					v["PlayersVoted"][player.Name] = false
					v["Votes"] = v["Votes"] - 1
				end
			end	
			
			Votes[argumentTable[2]]["PlayersVoted"][player.Name] = true
			Votes[argumentTable[2]]["Votes"] = Votes[argumentTable[2]]["Votes"] + 1
			return Votes
	elseif argumentTable[1] == "SaveUiDesign" then
		Save(DataStoreUiDesignStore,"UiFor: "..player.UserId,argumentTable[2])
	elseif argumentTable[1] == "ReturnDustValue" then
		return player:WaitForChild("leaderstats"):WaitForChild("Dust").Value
	elseif argumentTable[1] == "ReturnExpValue" then
		return player:WaitForChild("leaderstats"):WaitForChild("EXP").Value
	elseif argumentTable[1] == "ReturnMaxExpValue" then
		return player.MaxEXP.Value
	elseif argumentTable[1] == "GetMaps" then
		local ab = {}
		for i,v in pairs(MapsChildren) do
			ab[#ab+1] = v.Name
		end
		return ab
	end
end
end

also heres the error on the client bad argument #3 to 'Text' (string expected, got nil) Thanks for spending your time for my question!

4 comments

0

The error seems to be that you are trying to change a TextLabels orr Any Text thing's text to Nil i co'nt find where tho

0

can't*

0

It returns nil

0

I dont want it to return nil it prints 1 but returns nil