Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Unable To Cast Value To An InvokeClient ?

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

-- Inside The part
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)
-- 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

1 answer

  • I forget to mention the Error Is: Unable to cast value to object

1 comment

0

What line? And instead of answering edit your post, people don't usually answer things that have already been answered.

This discussion is preserved as it was. New answers, comments, and votes are closed.