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

How to fix that problem? (a nil value)

Asked by 5 years ago

Error: Players.Diltz_3.PlayerGui.BookingGUI.MainScript:24: attempt to index local 'PlrName' (a nil value)

> FireServer: (LocalScript)

local EventRefreshRequest = game.ReplicatedStorage:WaitForChild("DataRefresh")

FindBTN.MouseButton1Click:connect(function()
    EventRefreshRequest:FireServer(PlrBox)
end)

OnServerEvent (Script)

local EventRefreshRequest = game.ReplicatedStorage.DataRefresh
local EventRefreshSend = game.ReplicatedStorage.DataRefreshSend
local SS = game:GetService("ServerStorage")

EventRefreshRequest.OnServerEvent:connect(function(Player,PlrBox)
    if SS:FindFirstChild(PlrBox.Text) then
        local Breakfast = SS:FindFirstChild(PlrBox.Text).Breakfast
        local Lunch = SS:FindFirstChild(PlrBox.Text).Lunch
        local Dinner = SS:FindFirstChild(PlrBox.Text).Dinner
        local Class = SS:FindFirstChild(PlrBox.Text).Class
        local Drink = SS:FindFirstChild(PlrBox.Text).Drink
        local PlrName = SS:FindFirstChild(PlrBox.Text).PlrName
        EventRefreshSend:FireClient(Player,Breakfast,Class,Dinner,Drink,Lunch,PlrName)
    end
end)

> OnClientEvent (LocalScript)

local EventRefreshSend = game.ReplicatedStorage:WaitForChild("DataRefreshSend")

EventRefreshSend.OnClientEvent:connect(function(Player,Breakfast,Class,Dinner,Drink,Lunch,PlrName)
    NameBox.Text = PlrName.Value
    ClassBox.Text = Class.Value
    BreakfastBox.Text = Breakfast.Value
    LunchBox.Text = Lunch.Value
    DinnerBox.Text = Dinner.Value
    DrinkBox.Text = Drink.Value
end)
0
PlrName.Value in the last script The_Pr0fessor 595 — 5y
0
identify it again "PlrName = " The_Pr0fessor 595 — 5y
0
OnClientEvent local script, remove the Player parameter. You don’t pass it for anything. User#19524 175 — 5y

Answer this question