Question is pretty much self explanatory, let's say I made a flag, could I assign it to 'flag' and run Instance.new('flag') to get it to spawn in?
put this in a local script a place it into the startergui.
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local command = "Your command here" game:GetService("Players").LocalPlayer.Chatted:connect(function(msg) if string.sub(msg,1) == command then local flag-- = your object here local flagclone = flag:Clone() flagclone.Parent = workspace if flagclone:IsA("Model") then if flagclone.PrimaryPart then for i,v in pairs(flagclone:GetChildren()) do if v:IsA("BasePart") then v.Anchored = true end end flagclone:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame* CFrame.new(0,0,-3)) end elseif flagclone:IsA("BasePart") then flagclone.Anchored = true flagclone.CFrame = char.HumanoidRootPart.CFrame* CFrame.new(0,0,-3) end end end)
No, but however you make the flag, you could store it somewhere (ex in ReplicatedStorage) and :Clone()
it when you want another one. (If it's a Model, you may need to :MakeJoints()
after you Clone it). ex:
local origFlag = game.ReplicatedStorage.Flag --When you want a new one: local newFlag = origFlag:Clone() newFlag:MakeJoints() newFlag.Parent = workspace
You can have scripts inside the flag if you want special functionality. Alternatively, you can make your own function in (for example) a ModuleScript that creates the flag, sets up events, and anything else you want.