Hi, I'm making a pick-up system but it doesn't work. There will be an error.
Client script:
local Player = game:GetService("Players").LocalPlayer local Mouse = Player:GetMouse() local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("LootPickup") Mouse.Button1Down:Connect(function() RemoteEvent:FireServer(Player, Mouse) end)
Server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("LootPickup") RemoteEvent.OnServerEvent:Connect(function(Player, Mouse) if Player then local Target = Mouse.Target if Target:FindFirstChild("Loot") then Target:Destroy() print("Succesfully picked up loot.") end end end)
Error: Target is not a valid member of Player, line 11 in the Server script.
At the client instead of Player, Mouse does just Mouse because it thinks that the mouse is inside player, If you know much about remote events at onserverevent you always gotta put Player already!