I've tried every tutorial I've found on every possible platform, but to no avail. Can anyone show me the proper way to convert this to a working LocalScript without it breaking? The script is completely functional on Studio but not the game itself.
repeat wait() until game.Players.LocalPlayer.Character
wait(1)
game:GetService("Players")
local player = game.Players.LocalPlayer
local egghunt = player.Character.Humanoid
print("Cash")
function onPlayerEntered(newPlayer)
wait(.25)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local stats2 = Instance.new("IntValue")
stats2.Name = "Cash"
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = stats
stats2.Parent = newPlayer
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
----------------------------------------------------------------
ZombieWaveTime = math.random (60) --put how long in seconds wave
InbetweenZombieWaveTime = 10 -- inbetween zombie wave
MessageShowTime = 5 -- announcement messages
while true do
local msg = Instance.new("Message")--Copy from here
msg.Parent = game.Workspace
msg.Text = ("Let's wait 15 seconds for other people to join.")
wait(5)
msg:remove()
wait(5)
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("The game will begin in 1 minute.")
wait(5)
msg:remove()
wait(5)
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("The game will begin in 30 seconds!")
wait(5)
msg:remove()
wait(5)
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("The game begins in 5...")
wait(1)
msg.Text = ("The game begins in 4...")
wait(1)
msg.Text = ("The game begins in 3...")
wait(1)
msg.Text = ("The game begins in 2...")
wait(1)
msg.Text = ("The game begins in 1...")
wait(1)
msg:remove()
wait(1/30)--
target = CFrame.new(0, 50, 0)
for i, player in ipairs(game.Players:GetChildren()) do
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
--offset of 5
end
wait(1)
local PlayersDied = 0
egghunt.Died:connect(function ()
PlayersDied = PlayersDied + 1
if PlayersDied >= game.Players.NumPlayers then -- if someone left
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("The game is over!")
wait(5)
msg:remove()
script.Disabled = true
PlayersDied = 0 --Reset the dead count
end
end)
local msg = Instance.new("Message")--Copy from here
msg.Parent = game.Workspace
msg.Text = ("Wave 1")--
wait(5)--
msg:remove()
game.Lighting.Wave1:clone().Parent = game.Workspace
game.Workspace.Wave1:MakeJoints()
wait(ZombieWaveTime)
game.Workspace.Wave1:remove()
wait(InbetweenZombieWaveTime)
----------------------------------
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Wave 2")
wait(5)
msg:remove()
game.Lighting.Wave2:clone().Parent = game.Workspace
game.Workspace.Wave2:MakeJoints()
wait(ZombieWaveTime)
game.Workspace.Wave2:remove()
wait(InbetweenZombieWaveTime)
----------------------------------
end

1 comment
So would separating the scripts be the best way to go with this? And if so, what parts would I separate?