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

Remote Event FindFirstChild is returning Nil?

Asked by 8 years ago
Edited 8 years ago

I'm currently working on a placement system that runs on Filtering Enabled, but my remote is causing some weird and unusual errors. The script works perfectly locally, but the script breaks when it comes to the remote event. I do know that the script is returning that the item I'm passing through (in this case, "Block" has "Nil"), despite having an item called "Block" already in the correct location. Is there a chance that anyone could help me?

My script:

local PlaceItem = game.ReplicatedStorage:FindFirstChild("Remotes"):WaitForChild("PlaceItem")

PlaceItem.OnServerEvent:connect(function(plr,IName,Par,Pos)
    print("Testing")
    print(IName)
    local Item = game.ReplicatedStorage:FindFirstChild("Models"):FindFirstChild(IName)
    print(Item)
    if Item then
        print("Found Item") 
        local NewItem = Item:Clone()
        print("Cloned item")
        NewItem.Parent = Par
        print("Setting the parent")
        if NewItem:FindFirstChild("HitBox") then
            NewItem.HitBox.Transparency = 1
            NewItem.HitBox.CanCollide = false
            NewItem.PrimaryPart = NewItem.HitBox
            NewItem:SetPrimaryPartCFrame(Pos)
            print("Placed cloned model")
        end
    end
end)
1
Can you show both scripts? RemoteEvents can't return values, RemoteFunctions can. TheDeadlyPanther 2460 — 8y

Answer this question