-
What do you want to achieve?
I’m trying to make a button that deletes the pet from a slot. To tell the script which slot to delete, I’m using a NumberValue which changes depending on the selected slot. -
What is the issue?
The NumberValue assigned to the table doesn’t change even if I change it manually or with scripts. -
What solutions have you tried so far?
None because I couldn’t find any on the dev forum nor other lua websites.
local player = game.Players.LocalPlayer
local SelectedValue = script.Parent.Parent.SelectedSlot.Value
local PetID = script.Parent.Parent.PetID.Value
local Inventory = script.Parent.Parent.Parent.Inventory
script.Parent.MouseButton1Click:Connect(function()
local SelectedSlot = {
[0] = function()
script.Parent.NoSelectedPet:Play()
print("No slot was selected")
end,
[1] = function()
Inventory.Slot1.PetID.Value = 0
Inventory.Slot1.PetImage.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
Inventory.Slot1.PetName.Text = "No pet"
Inventory.Slot1.Active = false
print("Slot 1 deleted")
end,
[2] = function()
Inventory.Slot2.PetID.Value = 0
Inventory.Slot2.PetImage.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
Inventory.Slot2.PetName.Text = "No pet"
Inventory.Slot2.Active = false
print("Slot 2 deleted")
end,
[3] = function()
Inventory.Slot3.PetID.Value = 0
Inventory.Slot3.PetImage.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
Inventory.Slot3.PetName.Text = "No pet"
Inventory.Slot3.Active = false
print("Slot 3 deleted")
end,
[4] = function()
Inventory.Slot4.PetID.Value = 0
Inventory.Slot4.PetImage.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
Inventory.Slot4.PetName.Text = "No pet"
Inventory.Slot4.Active = false
print("Slot 4 deleted")
end,
[5] = function()
Inventory.Slot5.PetID.Value = 0
Inventory.Slot5.PetImage.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
Inventory.Slot5.PetName.Text = "No pet"
Inventory.Slot5.Active = false
print("Slot 5 deleted")
end
}
SelectedSlot[SelectedValue]()
end)
The output always comes out as “No slot was selected” ([0] on the table).
The NumberValue is set to 0.
The NumberValue is changed by scripts when you select a slot.