What’s up my dudes, I’m currently making a model which I want to be able to be inserted via a admin command system. The problem is that I’m using GUI’s for it to work which obviously means that they are getting stuff from the model which would and will interfere with multiple instances because of that I would like to know how would a make it that when I spawn it ingame that it will check for any other instancese of it already ingame and if there are that it will rename itself to for example “Inserted2” instead of “Inserted1”
Could you give us the script please? Without much information, we won’t be able to find the solution or problem with your script.
I didn’t really get what you mean but I’m guessing your trying to get models a increased number inside their name. You can use loops and string.gsub or string.match to do this.
for _, object in pairs(location:GetDescendants()) do
local number = string.match(object.Name, 'Inserted(%d+)')
if number then
object.Name = 'Inserted' .. tonumber(number) + 1
end
end
Alright here you go;
local g = game.Workspace.MedSys
local p = script.Parent
local function F()
print("Local F has been fired")
if g.CustomNameV.Value == false then
g.CustomNameV.Value = true
p.CustomNameButton.Text = "X"
p.EnterName.TextEditable = true
else
if g.CustomNameV.Value == true then
g.CustomNameV.Value = false
p.CustomNameButton.Text = ""
p.EnterName.TextEditable = false
end
end
end
p.CustomNameButton.MouseButton1Click:Connect(F)
local function I1()
g.InjuryV.Value = p.Injurs.AcResponse.Text
end
p.Injurs.AcResponse.MouseButton1Click:Connect(I1)
local function I2()
g.InjuryV.Value = p.Injurs.AcNoResponse.Text
end
p.Injurs.AcNoResponse.MouseButton1Click:Connect(I2)
local function onChanged()
print("OnChanged")
g.AllCheckedV.Value = true
end
g.InjuryV.Changed:Connect(onChanged)
local function F1()
print("Trying to Proceed..")
if g.AllCheckedV.Value == true then
print("Proceeding..")
p.Parent.Parent.Enabled = false
wait(5)
g.AllCheckedV.Value = false
end
end
p.ProceedButton.MouseButton1Click:Connect(F1)
First of all, I’m still pretty new to this so there might be a better way to do this or something in there. Second, in case the script dosen’t help let me make it a bit clearer for what I need: I’m having the problem that my script is in a gui which is cloned into the player starter gui when a proximity prompt is triggered which works fine, the problem starts here though the player now has that GUI which if there only is one thing of this in game then it’s fine but I want it to be cloned and having multiple of these models in game but that dosen’t work because of same name and I want to know if It is possible to write something that will either detect if there are other models already ingame and then rename the model so it won’t conflict or there is a way to rewrite the script without having to rename the model hope this makes it clearer if you need a picture of the structer of the model please respond to this and say that you need one!