for some reason the server wont return a bool value or maybe the client isn't picking it up, please help. Btw i have left the rest of the code out because it is unnecessary and is hard to read.
Client:
Uis.InputBegan:Connect(function(inputObject) if inputObject.KeyCode == Enum.KeyCode.E then if mouse.Target ~= nil then part = mouse.Target part = part:FindFirstAncestorWhichIsA("Model") if part then local ig = reqGrab:InvokeServer(part) -- the remote function if ig == true then -- the problem print(123456) isGrabbing = true end end end end end)
Server:
function requestGrab(player, part) if playerParts[part] ~= nil then return false end -- will not let code run if part is associated with a player, if collectionService:HasTag(part, tag) then local primaryPart = part:FindFirstChild("PrimaryPart") if primaryPart then playerParts[part] = player applyConfig(part) for i, v in pairs(part:GetChildren()) do v:SetNetworkOwner(player) end print(part.Name .. " Successfully claimed!") return true -- i want this value to be returned to the client side end end end
I don't think you can search the primary part using :FindFirstChild(), thats why the findfirstchild will return nil and inside it is the return so without the primary part == true, it will return nil, and also mouse.Target can only get parts, I don't think it can get models or tools, try
if part.Parent:IsA("Model") local primaryPart = part.Parent.PrimaryPart if primaryPart then -- Your code end end