I'm making a game, and in the game you have to collect food and things, how do I remove a part when collected since Mouse.Target is Read Only? And I tried using GetFullName().
elseif Target:findFirstChild("Food") then if not FoodDebounce then FoodDebounce = true if Food.Value < Food.Max.Value then Food.Value = Food.Value + 5 end if Food.Value > Food.Max.Value then Food.Value = Food.Max.Value end local Part = Target:GetFullName() Part:Remove() wait(2) FoodDebounce = false end
GetFullName is a method that returns a string that contains the path to that instance. For example, if there was a part in workspace, using GetFullName on that part would return 'game.Workspace.Part'
So you are trying to remove the part name instead of the actual part.
To fix this, you just have to instead do:
target:Destroy() wait(2) FoodDebounce = false
Is it read only?
elseif Target:findFirstChild("Food") then if not FoodDebounce then FoodDebounce = true if Food.Value < Food.Max.Value then Food.Value = Food.Value + 5 end if Food.Value > Food.Max.Value then Food.Value = Food.Max.Value end local Part = Target Part:Destroy() wait(2) FoodDebounce = false end
I'm pretty sure it's not read only. Anyways, I changed :Remove() to :Destroy().