Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago

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()

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 blueboy90780 74 — 7y
0
What is the error exactly? FrostTaco 90 — 7y
0
The function doesn't perform at all. Also, most of the print functions just return nil. animorphs30 300 — 7y
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 iamnoamesa 674 — 7y
View all comments (2 more)
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. animorphs30 300 — 7y
0
Really? At least tell us what your trying to do SH_Helper 61 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago

Players = game.Players:GetChildren()

This will never update

Ad
Log in to vote
0
Answered by 7 years ago

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.

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

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"

Answer this question