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

attempt to index nil with leaderstats (remote events) how to fix?

Asked by 2 years ago

the error script (its receiving remote script)t:

game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(falls, item, plr)
    print(falls)
    print(item)
    print(plr)
    if game.Players:FindFirstChild(plr).leaderstats["???????"].Value == falls then
        game.ReplicatedStorage.items:FindFirstChild(item):Clone().Parent = game.Players:FindFirstChild(plr).Backpack
    elseif game.Players:FindFirstChild(plr).leaderstats["???????"].Value > falls then
        game.ReplicatedStorage.items:FindFirstChild(item):Clone().Parent = game.Players:FindFirstChild(plr).Backpack
    else
        plr:Kick("????????: false")
    end
end)

now the sending script

script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.leaderstats["???????"].Value == script.Parent.falls.Value then
        workspace.alert:Play()

         game.ReplicatedStorage.Remote:FireServer(script.Parent.falls.Value, 
 script.Parent.item.Value, game.Players.LocalPlayer.Name)
     elseif game.Players.LocalPlayer.leaderstats["???????"].Value > script.Parent.falls.Value 
 then
         workspace.alert:Play()

         game.ReplicatedStorage.Remote:FireServer(script.Parent.falls.Value, 
 script.Parent.item.Value, game.Players.LocalPlayer.Name)
     end

 end)

if anyone could help that would be great

0
First of all, you shouldn't trust the client. Second of all, Events in general don't support tuples, so you have to send dictionaries instead. Third of all, the first argument of a OnServerEvent is the player that sent it, so you don't have to specify the player from the client. RAFA1608 543 — 2y
0
I'm not sure about the "not supporting tuples" part, but in my experience, it doesn't work that way. RAFA1608 543 — 2y
0
thanks winnydows 0 — 2y

Answer this question