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:
01 | Uis.InputBegan:Connect( function (inputObject) |
02 | if inputObject.KeyCode = = Enum.KeyCode.E then |
03 | if mouse.Target ~ = nil then |
04 | part = mouse.Target |
05 | part = part:FindFirstAncestorWhichIsA( "Model" ) |
06 | if part then |
07 | local ig = reqGrab:InvokeServer(part) -- the remote function |
08 | if ig = = true then -- the problem |
09 | print ( 123456 ) |
10 | isGrabbing = true |
11 | end |
12 | end |
13 | end |
14 | end |
15 | end ) |
Server:
01 | function requestGrab(player, part) |
02 | if playerParts [ part ] ~ = nil then return false end -- will not let code run if part is associated with a player, |
03 | if collectionService:HasTag(part, tag) then |
04 | local primaryPart = part:FindFirstChild( "PrimaryPart" ) |
05 | if primaryPart then |
06 | playerParts [ part ] = player |
07 | applyConfig(part) |
08 | for i, v in pairs (part:GetChildren()) do |
09 | v:SetNetworkOwner(player) |
10 | end |
11 | print (part.Name .. " Successfully claimed!" ) |
12 | return true -- i want this value to be returned to the client side |
13 | end |
14 | end |
15 | 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
1 | if part.Parent:IsA( "Model" ) |
2 | local primaryPart = part.Parent.PrimaryPart |
3 | if primaryPart then |
4 | -- Your code |
5 | end |
6 | end |