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

I broke a scipt by editing another one?

Asked by
tber8 37
7 years ago

I went into my game after testing this script and having it work:

local function onPlayerEntered(newPlayer)
    newPlayer.CameraMaxZoomDistance = 8
    newPlayer.Character.Torso.CFrame = game.Workspace.Tele2.CFrame
    local lol = script.MenuGui:Clone()
    local lol2 = script.StartGui:Clone()
    lol.Sound.Playing = true
    lol.Parent = newPlayer.PlayerGui
    lol2.Frame.Script.Disabled = false
    lol2.Frame.TextLabel2.Script.Disabled = false
    lol2.Parent = newPlayer.PlayerGui
end 

game.Players.PlayerAdded:connect(onPlayerEntered) 

This script causes the start menu and start animation GUI to open. It turns on the menu music and animation scripts. It also changes how far out a player can scroll.

After adding a new section to my game's main script, that script broke 100%. Not one thing in the script worked, while the main script worked. The addition to the main script was the following:

math.randomseed(os.time());
    local list = {};
    function foo()
    for index, child in pairs(game.ReplicatedStorage.Maps:GetChildren()) do
        wait();
        list[index] = child;
    end
    randomMap = list[math.random(1,table.getn(list))]:Clone();
    randomMap.Parent = game.Workspace.MapHolder;

end
foo();

locations = randomMap.Spawns

for _,v in pairs(game.Players:GetChildren()) do
    local spawnlocation = locations:FindFirstChild('Part')
    v.Character.Torso.CFrame = spawnlocation.CFrame
    spawnlocation.Parent = spawnlocation.Parent.Parent
end

Feel free to comment a question. I need all the help I can get.

0
Is there any error in output? Put prints all over your code to make sure that it is running. IcedVapour 153 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago
Edited 7 years ago

Those two scripts shouldn't affect each other anywhere except for the v.Character.Torso.CFrame = spawnlocation.CFrame line in the second script. Try putting print statements and/or breakpoints in various parts of your code to see what runs when.

Are you sure you even know what this code does? Your inconsistent usage of semicolons and indentation levels makes it look like you copied parts of it from somewhere else.

0
I already tried printing and I checked using various tests. Not a single piece actually works. tber8 37 — 7y
Ad

Answer this question