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

Players.player.PlayerGui.LocalScript:4: attempt to index local 'player' (a nil value) How to fix?

Asked by 5 years ago

when the script runs, i get an error Players.ieatandisbaconhair.PlayerGui.LocalScript:4: attempt to index local 'player' (a nil value). How do i fix it? thanks!

script:

local debounce = false
local cam = game.Workspace.CurrentCamera
game.ReplicatedStorage.EnterPaintShop.OnClientEvent:Connect(function(player)
    local player = player
            for i,v in pairs(player.Character:GetChildren())do
    if v:IsA("Model") and v.Name == player.Name.."'s Car" then
    v:Destroy()
    end
    for _,k in pairs(cam:GetChildren())do
    k:Destroy()
    end
    if not debounce then
    debounce = true
    local c = player:WaitForChild("SelectedCar").Value:Clone()
    c.Parent = game.Workspace.CurrentCamera
    c:SetPrimaryPartCFrame(game.Workspace.painttp.CFrame)
    player.Character.Torso.CFrame = player.Character.Torso.CFrame + Vector3.new(3,0,3)
    player.Character.Humanoid.WalkSpeed = 0
    player.PlayerGui.PaintGUI.Enabled = true
    cam.CameraSubject = game.Workspace.painttp
    debounce = false
        end
        end
end)
0
There's no built in player argument with OnClientEvent, the variable `player` is nil unless you specifically sent an argument via the server Vulkarin 581 — 5y
0
oh, thanks! ieatandisbaconhair 77 — 5y
0
Vulk, I thought it was opposite... greatneil80 2647 — 5y
0
No problem Vulkarin 581 — 5y
View all comments (4 more)
0
Shouldn't be the opposite, OnServerEvent has the argument built in because it needs to know which client fired the event, OnClientEvent on the other hand can only be sent from the server Vulkarin 581 — 5y
0
When i step in the pad, nothing is happening. i used for i,v game ieatandisbaconhair 77 — 5y
0
well make sure you got the :FireServer method aazkao 787 — 5y
0
this is supposed to show a gui for a player when a player steps in a pad ieatandisbaconhair 77 — 5y

Answer this question