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

I don't know whats wrong it was working before in the script most of functions are working?

Asked by 2 years ago
local plrC = 0
local function gamestart()
    print("Yes")
    for keyvalue, player in pairs(game.Players:GetPlayers()) do
        local num = math.random(1,5)
        if game.Workspace.Seats:FindFirstChild(num).Value.Value == "None" then
            game.Workspace.Seats:FindFirstChild(num).Value.Value = player.Name
            game.Workspace.Seats:FindFirstChild(num):Sit(player.Character.Humanoid)
            game.Workspace:WaitForChild("GameStarted").Value = true
            local PlayerNumberSeat = Instance.new("NumberValue")
            PlayerNumberSeat.Parent = player.Character
            PlayerNumberSeat.Value = num 
        end
    end
end
game.Workspace.GameStarted.Changed:Connect(function()
    if game.Workspace.GameStarted.Value == true then
    local playerService = game:GetService("Players")
    local Players = playerService:GetPlayers()
    local RandomPlayer = Players[math.random(#Players)]
    game.ReplicatedStorage.PickPlayer:FireClient(RandomPlayer)
    local RandomPlayerWork = game.Workspace:FindFirstChild(RandomPlayer.Name)
    local WeaponAim = game.ServerStorage.LocalLookingAroundScript:Clone()
    WeaponAim.Disabled = false
    WeaponAim.Parent = RandomPlayerWork
    print(RandomPlayer.Name)
    local gun = game.ServerStorage.Deagle:Clone()
        gun.Parent = RandomPlayerWork
        game.ReplicatedStorage.PickPlayer:FireClient(RandomPlayer)
        game.ReplicatedStorage.PickPlayer.OnServerEvent:Connect(function() 
            local SeatNumber = RandomPlayerWork.Value.Value 
            SeatNumber = SeatNumber + 1
            local playerName = game.Workspace.Seats:FindFirstChild(SeatNumber).Value.Value
            print(playerName)
            SeatNumber = SeatNumber - 1
            print(playerName)
            local Nextplayer = game.Workspace:FindFirstChild(playerName)
            local WeaponAim = game.ServerStorage.LocalLookingAroundScript:Clone()
            WeaponAim.Disabled = false
            WeaponAim.Parent = Nextplayer 
            print(RandomPlayer.Name)
            local gun = game.ServerStorage.Deagle:Clone()
            gun.Parent = Nextplayer
        end)


        local function PlayerCountChecker()
            print("Yes")
    if plrC >= 2 then
        game.ReplicatedStorage.Intermisson:FireAllClients()
        wait(6.5)
        gamestart()
    elseif plrC <= 1 then
        game.ReplicatedStorage.NotEnoughPlayers:FireAllClients(plrC)
            end
            local function PlayerAdded()
                plrC = plrC + 1
                PlayerCountChecker()
            end
            game.Players.PlayerAdded:Connect(PlayerAdded)
            for i,v in next,game.Players:GetPlayers() do
                PlayerAdded()
            end
    game.Players.PlayerRemoving:Connect(function()
                plrC = plrC - 1
                PlayerCountChecker()
            end)
            end
        end
end)

0
Can you please elaborate more? What did you try? What is the error and which line is it in? PaleNoobs 37 — 2y
0
Theres no errors the Playeradded function is not working robot7866 36 — 2y
0
Try adding some prints in there MaleficentMaestro 109 — 2y
0
It doesnt fire cus the functions dont work robot7866 36 — 2y

Answer this question