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

Why isn't my script working?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I tried asking on the roblox forum but that didn't help at all. In this script, I'm trying to give every player a gun, give them a string value, and teleport them to the map. When I uploaded my game to roblox, first of all, only one player received the gun, and second of all, no one was teleported. Do you guys see any issues?

local spawns = arenaclone:WaitForChild("Spawns"):GetChildren()
print('a')
for _, player in pairs(game.Players:GetPlayers()) do 
    if player and #spawns > 0 then
        print('b')
        local backpack = player:WaitForChild("Backpack")
        local hyperlaser = replicatedstorage.HyperLaser
        tool = hyperlaser:Clone()
        tool.Parent = backpack
        local matchtag = Instance.new("StringValue")
        matchtag.Name = "MatchTag"
        matchtag.Parent = player.Character
        print('c')
        local torso = player.Character:WaitForChild("Torso")
        local allspawns = math.random(1, #spawns)
        local randomspawn = spawns[allspawns]
        if randomspawn and torso then
            print('d')
            table.remove(spawns, allspawns)
            torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0, 2, 0))
            print('e')
        end
    end
end
0
Are the prints you have stopping anywhere, are there any errors in the Dev Console/Output? M39a9am3R 3210 — 8y
0
I could bet the errors are situated on one of the WaitForChild()s. TheDeadlyPanther 2460 — 8y

Answer this question