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

why isn't my remote function returning a bool?

Asked by 4 years ago
Edited 4 years ago

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:

01Uis.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
15end)

Server:

01function 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
15end
0
any output? VitroxVox 884 — 4y
0
nope no errors and the print doesn't run Code1400 75 — 4y
0
it is equal to nil Code1400 75 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

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

1if part.Parent:IsA("Model")
2    local primaryPart = part.Parent.PrimaryPart
3    if primaryPart then
4        -- Your code
5    end
6end
0
i found the solution to the problem, i forgot i was calling the function from another function and returning the bool only returned it to the function it was in. and i named one of the parts in the model primary part, im not actually referencing the primarypart property of a model, and the variable part is changed in the next line to the parent "Model". ill accept your answer Code1400 75 — 4y
Ad

Answer this question