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

Unable To Cast Value To Object On an InvokeClient()?

Asked by
Simnico99 206 Moderation Voter
8 years ago

This is in a part and its sending this information to a localscript in a player Idk why it doesnt Work

Line 15 Error: Unable to cast value to object FilteringEnabled Is ON Its the script of the part in the workspace

AlreadyClicked = false
script.Parent.PlayerName.Changed:connect(function()                                     
                    if AlreadyClicked == false then
                    AlreadyClicked = true
                    local PlayerName = script.Parent.PlayerName.Value
                    local Player = script.Parent.PlayerName.Value
                    local Level = script.Parent.Level.Value
                    local DescLine = script.Parent.DescLine.Value
                    local NameLine = script.Parent.NameLine.Value
                    local IsSword = script.Parent.IsSword.Value
                    local IsHelmet = script.Parent.IsHelmet.Value
                    local IsLegging = script.Parent.IsLegging.Value
                    local IsChestPlate = script.Parent.IsChestPlate.Value
                    local ImageId = script.Parent.ImageID.Value
                        local success, result = pcall(function() return game.Players[PlayerName].PlayerGui.LocalWriter.OnLoot:InvokeClient(Player, Level, DescLine, NameLine, IsSword, IsHelmet, IsLegging, IsChestPlate, ImageId) end)
                        print(result)
                        if success then
                        if result ~= "Full" then
                        script.Parent:Destroy()
                        elseif result == "Full" then
                        AlreadyClicked = false
                        end
                        else
                        print("Can't Write Inventory")
                        end
                        end             
        end)

Thats Inside the localscript

EmptySlot = nil
function script.OnLoot.OnClientInvoke(Player, Level, DescLine, NameLine, IsSword, IsHelmet, IsLegging, IsChestPlate, ImageId)
local SlotLocation = script.Parent.Backpack.Slots
local FullInv = script.Parent.Backpack.Open
                    if SlotLocation.Slot1.Found.Value==false then
                        EmptySlot="Slot1"
                    elseif SlotLocation.Slot2.Found.Value==false then
                        EmptySlot="Slot2"
                    elseif SlotLocation.Slot3.Found.Value==false then
                        EmptySlot="Slot3"
                    elseif SlotLocation.Slot4.Found.Value==false then
                        EmptySlot="Slot4"
                    elseif SlotLocation.Slot5.Found.Value==false then
                        EmptySlot="Slot5"
                    elseif SlotLocation.Slot6.Found.Value==false then
                        EmptySlot="Slot6"
                    elseif SlotLocation.Slot7.Found.Value==false then
                        EmptySlot="Slot7"
                    elseif SlotLocation.Slot8.Found.Value==false then
                        EmptySlot="Slot8"   
                    elseif SlotLocation.Slot9.Found.Value==false then
                        EmptySlot="Slot9"
                    elseif SlotLocation.Slot10.Found.Value==false then
                        EmptySlot="Slot10"
                    elseif SlotLocation.Slot11.Found.Value==false then
                        EmptySlot="Slot11"
                    elseif SlotLocation.Slot12.Found.Value==false then
                        EmptySlot="Slot12"
                    elseif SlotLocation.Slot13.Found.Value==false then
                        EmptySlot="Slot13"
                    elseif SlotLocation.Slot14.Found.Value==false then
                        EmptySlot="Slot14"
                    elseif SlotLocation.Slot15.Found.Value==false then
                        EmptySlot="Slot15"
                    elseif SlotLocation.Slot16.Found.Value==false then
                        EmptySlot="Slot16"  
                    else
                        EmptySlot="Full"
                        FullInv.Full.Visible = true
                        wait(4)
                        FullInv.Full.Visible = false
                        return "Full"                                       
                    end
                    if EmptySlot~="Full" then                               
                        game.Workspace.Function.InventoryWriter.Loot:InvokeServer(EmptySlot, NameLine)          
                        SlotLocation:FindFirstChild(EmptySlot).Image.Image= ImageId
                        SlotLocation:FindFirstChild(EmptySlot).Image.ItemName.Value = NameLine
                        SlotLocation:FindFirstChild(EmptySlot).Image.IsSword.Value = IsSword
                        SlotLocation:FindFirstChild(EmptySlot).Image.IsChestPlate.Value = IsChestPlate
                        SlotLocation:FindFirstChild(EmptySlot).Image.IsHelmet.Value = IsHelmet
                        SlotLocation:FindFirstChild(EmptySlot).Image.IsLegging.Value = IsLegging
                        SlotLocation:FindFirstChild(EmptySlot).Image.ItemDesc.Value = DescLine
                        SlotLocation:FindFirstChild(EmptySlot).Image.ImageID.Value = ImageId
                        SlotLocation:FindFirstChild(EmptySlot).Image.Level.Value = Level                        
                        SlotLocation:FindFirstChild(EmptySlot).Found.Value=true
                        game.Workspace.SaveServices.Save:InvokeServer()         
                        return "Sucess"
                    end
end

Answer this question