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

I broke a scipt by editing another one?

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.

1 comment

0

Is there any error in output? Put prints all over your code to make sure that it is running.

1 answer

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.

1 comment

0

I already tried printing and I checked using various tests. Not a single piece actually works.

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