local f = {}
local servStorage = game:GetService('ServerStorage'):WaitForChild('Toons')
local value = game.Workspace.ValuesFolder.ToonValue
local ToonList = {
["BearToon"] = 1, ["GoatToon"] = 2, ["CatToon"] = 3, ["ChickenToon"] = 4, ["RabbitToon"] = 5, ["DogToon"] = 6, ["CowToon"] = 7, ["DuckToon"] = 8, ["MouseToon"] = 9, ["PigToon"] = 10, ["MonkeyToon"] = 11, ["HorseToon"] = 12
}
-- gets the toon name from its id
function getToonNameFromId(toonID)
for i, v in pairs(ToonList) do
if v == toonID then return i end
end
return nil -- if not found
end
-- gets the toon id from its name
function getToonIdFromName(toonName)
return ToonList[toonName] -- this will be nil if not found
end
value.Changed:connect(function(NewValue)
if value.Value == getToonIdFromName then
local Toon = servStorage:WaitForChild(getToonNameFromId):clone().Parent = game.Workspace
Toon.Name = getToonNameFromId
end
end)
All i want is that the script looks at the intvalue and if the value is equal to the numbers in toonlist then it finds name and clones the model also it should destory a existing model n the workspace but im not sure how to do this.

1 comment
Can you use a table instead of an IntValue?