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

Whats wrong with this code? Nothing spawns or teleports

Here is the code

local maps = game.ReplicatedStorage.Maps:GetChildren()

while true do
    local allplayers = game.Players:GetPlayers()

    game.ReplicatedStorage.status.Value = "Intermission (20 Seconds)"
    wait (18)
    game.ReplicatedStorage.status.Value = "Selecting map, Hold On!"
    wait (2)
    game.ReplicatedStorage.Maps.Map1:Clone() .Parent = game.Workspace
    game.ReplicatedStorage.status.Value = "Map selected: Lab"
    wait (1)
    local allspawns = game.Workspace.Map1.Spawns:GetChildren()
    local randomspawn = allspawns[math.random(1, #allspawns)]
    for i, v in pairs(allplayers) do 
        v.Character.HumanoidRootPart.CFrame = randomspawn.CFrame
    end
    wait (2)
    game.ReplicatedStorage.status.Value = "Get Ready!"
    wait(5)
    game.ReplicatedStorage.status.Value = "Go!"
    game.ReplicatedStorage.Knife:Clone() .Parent = allplayers.Backpack
    game.ReplicatedStorage.Revolver:Clone() .Parent = allplayers.Backpack
    wait (180)
    for i, v in pairs(allplayers) do
            v.Character.Humanoid.Health = 0
    end
    wait (8)
    game.Workspace.Map1:Destroy()
end

3 comments

0

Does it give you any errors?

0

Does it give you any errors? and is it a Server Side script

0

Always check the output my man

1 answer

✓ Accepted answer

There are a few issues I can see right off the bat.

    game.ReplicatedStorage.Knife:Clone() .Parent = allplayers.Backpack
    game.ReplicatedStorage.Revolver:Clone() .Parent = allplayers.Backpack

This doesn't work because you are trying to parent the clones to a table. Here is a fixed version.

for i, v in pairs(allplayers) do
	local revolverClone = game.ReplicatedStorage.Revolver:Clone()
	local knifeClone = game.ReplicatedStorage.Knife:Clone()
	revolverClone.Parent = v.Backpack
	knifeClone.Parent = v.Backpack
end

I don't really know why the map isn't spawning in. Are you sure it's in the folder?

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