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

Fire client attempt to index local 'Player' (a nil value)?

Asked by 4 years ago
Edited 4 years ago

Fire client attempt to index local 'Player' (a nil value)

Can you help me?

Main Script - Server Script Service

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlrCamera = game.Workspace.CurrentCamera

local ServerStorage = game:GetService("ServerStorage")

local Status = ReplicatedStorage.Status

local Player = game:GetService("Players").LocalPlayer

local MapsFolder = game.ServerStorage.Maps

while true do

    wait(1)

    if game.Players.NumPlayers <2 then
        Status.Value = "Waiting for 2 players!"

        repeat wait(1) until game.Players.NumPlayers >= 2
        --Countdown (i used different style but i didn't work so i made it this way lol)
        Status.Value = "Break 20"
        wait(1)
        Status.Value = "Break 19"
        wait(1)
        Status.Value = "Break 18"
        wait(1)
        Status.Value = "Break 17"
        wait(1)
        Status.Value = "Break 16"
        wait(1)
        Status.Value = "Break 15"
        wait(1)
        Status.Value = "Break 14"
        wait(1)
        Status.Value = "Break 13"
        wait(1)
        Status.Value = "Break 12"
        wait(1)
        Status.Value = "Break 11"
        wait(1)
        Status.Value = "Break 10"
        wait(1)
        Status.Value = "Break 9"
        wait(1)
        Status.Value = "Break 8"
        wait(1)
        Status.Value = "Break 7"
        wait(1)
        Status.Value = "Break 6"
        wait(1)
        Status.Value = "Break 5"
        wait(1)
        Status.Value = "Break 4"
        wait(1)
        Status.Value = "Break 3"
        wait(1)
        Status.Value = "Break 2"
        wait(1)
        Status.Value = "Break 1"
        wait(1)
        Status.Value = "Break ended"
        wait(1)
        Status.Value = "Intermission 10"
        wait(1)
        Status.Value = "Intermission 9"
        wait(1)
        Status.Value = "Intermission 8"
        wait(1)
        Status.Value = "Intermission 7"
        wait(1)
        Status.Value = "Intermission 6"
        wait(1)
        Status.Value = "Intermission 5"
        wait(1)
        Status.Value = "Intermission 4"
        wait(1)
        Status.Value = "Intermission 3"
        wait(1)
        Status.Value = "Intermission 2"
        wait(1)
        Status.Value = "Intermission 1"
        wait(1)
        Status.Value = "Intermission"

        game.ReplicatedStorage.IsInGame.Value = true

        local plrs = {}

    for i, player in pairs(game.Players:GetPlayers())   do
        if player then
            table.insert(plrs,player)


    end
end

wait(2)

local AvailableMaps = MapsFolder:GetChildren()

local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

Status.Value = ChosenMap.Name.." Chosen"

local MapSpawn = ChosenMap:Clone()
MapSpawn.Parent = workspace

wait(2)

local Killer = {}

local KillerChosen = plrs[math.random(1,#plrs)]

Status.Value = "The killer is "..KillerChosen.Name

table.insert(Killer,1,KillerChosen)

wait(2)

wait()



Killer[1].Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(166.4, 110.3, 97.6)

game.ReplicatedStorage.CameraKillerBox:FireClient(Player(Player.Parent))

print("First event fired")

wait(8)

game.ReplicatedStorage.CameraKillerBoxBack:FireClient(Player(Player.Parent))

print("Second event fired")


    end
end

Local Script - Starter Gui

local Event = game.ReplicatedStorage.CameraKillerBox
local Event2 = game.ReplicatedStorage.CameraKillerBoxBack

Event.OnClientEvent:Connect(function()
    local KillerCamera = game.Workspace.CurrentCamera
    local Player = game.Players.LocalPlayer

    repeat wait() until Player.Character

    KillerCamera.CameraType = "Scriptable"
    KillerCamera.CFrame = game.Workspace.VeryDarkBox.KillerBoxCameraSurvivors.CFrame
end)

Event2.OnClientEvent:Connect(function()
    local KillerCamera = game.Workspace.CurrentCamera
    local Player = game.Players.LocalPlayer

    repeat wait() until Player.Character

    KillerCamera.CameraType = "Custom"
end)

Fire event doesn't work and please help me with Camera script (Local script) if it have any problems

0
psa: here is how to format your code on the site: https://gfycat.com/wanglamorousgermanspitz royaltoe 5144 — 4y
1
Also, is that your whole main script? In that context player doesn't exist royaltoe 5144 — 4y
0
Show us your whole Main Script and Local Script, otherwise it'll be difficult to tell what needs to be done. killerbrenden 1537 — 4y
0
I will show whole Main script tommorow because its currently almost midnight do i can't rights now kujekmarek 24 — 4y
0
Done you can check now kujekmarek 24 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

From what I see, you haven't assigned the 'Player' variable

Ad
Log in to vote
0
Answered by 4 years ago

You have attempted to index a local player from the servers side this can not be done

Answer this question