Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I solve this invisible Lua Code Error??? Any way to prevent this in the future???

I have come across an error in my code, but output apparently doesn't show any error, I'm curious to know what that error is. I've tried numerous things, such as printing outputs and checking the values being printed. Here's the code:

Players = game.Players:GetChildren()
Players1 = {}
Sniper = ""

function RandomSniper()
	local Random = math.random(0,#Players1)
	Sniper = Players1[Random]
	print(Sniper)
	return true
end

function PlayerToNumber()
	if game.ReplicatedStorage.InfoValue == "Intermission: 0" then
	for i,v in pairs(Players) do
		table.insert(Players1, i, v.Name)
		print(Players1[i])
	end
end
end

function SniperToPosition()
	print(RandomSniper())
	if RandomSniper() == true then
		local Sniper1 game.Players:FindFirstChild(Sniper)
		Sniper1.Character.Torso.Position = game.Workspace.SpawningPart.Position + Vector3.new(0,5,0)
		local Gun = game.ServerStorage.Sniper:Clone()
		Gun.Parent = Sniper1.Backpack
	end
end
PlayerToNumber()
RandomSniper()
SniperToPosition()

6 comments

0

I wasn't able to solve the problem, however I would like to say that I admire your ways of solving errors - I have never thought of using the print function this way since I thought it was completely useless. Ty to you, I manage to solve some of my own issues :D

0

What is the error exactly?

0

The function doesn't perform at all. Also, most of the print functions just return nil.

0

it is hard to find the error if you don't tell us what you want. You told us there was no error, but the result isn't what you wanted. tell us what you want, and what happens

0

The reason why I'm posting it here is that output doesn't show anything wrong with the script, but whenever I run it, nothing happens. It's supposed to chose a random player once a countdown ends, teleport them to a specific position and give them a gear, currently, it does nothing.

0

Really? At least tell us what your trying to do

3 answers

✓ Accepted answer

Players = game.Players:GetChildren()

This will never update

There are no invisible errors
Only silly mistakes

local Sniper1 game.Players:FindFirstChild(Sniper) isn't even Lua. Saying there's "no error" is absolute bollocks.

Really?? Use the wiki. The prints need to be like this.

print("Yay")
print(Boo)
print("Yay")
error("help im using prints wrong and i cant look it up on the wiki help")

Basiclly, when using a word, not when locating a part, use a string like this

game.Workspace:FindFirstChild("Part")

Also, prints dont show a error if it prints "nil" Use a helpful resource called "your brain"

This discussion is preserved as it was. New answers, comments, and votes are closed.