Alright, every time I say something, it should spawn about 5 blocks away. However, if I type something twice, it spawns in the same position. I don’t know how to fix this.
Any help would be appreciated.
script:
local LastPart = nil
for i = 1, 5, 1 do
local NP = Part:Clone()
NP.Parent = game.Workspace
LastPart = NP
NP.Position = LastPart.Position + Vector3.new(0, 1 , 0)
if LastPart == nil then
LastPart = StartPart
end
end
By the way, this is only half of the code. Let me know when you need the rest.
The “1” in the vector3 is set to the Y axis (Height) wich means your part will spawn at the same X and Y axis but in at different height. If you want to change the postion of the part, change the axis of the vector3. For example:
local LastPart = nil
for i = 1, 5, 1 do
local NP = Part:Clone()
NP.Parent = game.Workspace
LastPart = NP
NP.Position = LastPart.Position + Vector3.new(1, 0 , 0)
if LastPart == nil then
LastPart = StartPart
end
end
No, that’s not the problem. The Y-axis is what I want. However, for example, if I run it again, it spawns 5 again, but in the same position. I want it to spawn at the top of the other part, not in the same position.
I changed the part to ‘startpart’ to make it easier to understand.
local TopicsModule = require(script["Topicsmodule"])
local StartPart = game.Workspace:FindFirstChild("StartPart")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:PivotTo(StartPart.CFrame + Vector3.new(0, 5, 0))
player.Chatted:Connect(function(Chat)
for ind, topic in TopicsModule do
if Chat == string.lower(topic) then
local LastPart = nil
for i = 1, 5, 1 do
local NP = StartPart:Clone()
NP.Parent = game.Workspace
LastPart = NP
NP.Position = LastPart.Position + Vector3.new(0, 1 , 0)
if LastPart == nil then
LastPart = StartPart
end
end
end
end
end)
end)
end)
local TopicsModule = require(script["Topicsmodule"])
local StartPart = game.Workspace:FindFirstChild("StartPart")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:PivotTo(StartPart.CFrame + Vector3.new(0, 5, 0))
player.Chatted:Connect(function(Chat)
for ind, topic in TopicsModule do
if Chat == string.lower(topic) then
local LastPart = StartPart
for i = 1, 5, 1 do
local NP = LastPart:Clone()
NP.Parent = game.Workspace
NP.Position = LastPart.Position + Vector3.new(0, 1 , 0)
LastPart = NP
end
end
end
end)
end)
end)
It appears that you increment the Y value. Here’s the new code that increments the X value (if that’s what you’re looking for):
local TopicsModule = require(script["Topicsmodule"])
local StartPart = game.Workspace:FindFirstChild("StartPart")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:PivotTo(StartPart.CFrame + Vector3.new(0, 5, 0))
player.Chatted:Connect(function(Chat)
for ind, topic in TopicsModule do
if Chat == string.lower(topic) then
local LastPart = StartPart
for i = 1, 5, 1 do
local NP = LastPart:Clone()
NP.Parent = game.Workspace
NP.Position = Vector3.new(LastPart.Position.X + 1, LastPart.Position.Y, LastPart.Position.Z)
LastPart = NP
end
end
end
end)
end)
end)
local TopicsModule = require(script["Topicsmodule"])
local StartPart = game.Workspace:FindFirstChild("StartPart")
local Saved_Part = StartPart:Clone()
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:PivotTo(StartPart.CFrame + Vector3.new(0, 5, 0))
player.Chatted:Connect(function(Chat)
for ind, topic in TopicsModule do
if Chat == string.lower(topic) then
for instance_value = 1, 5, 1 do
local NP = Saved_Part:Clone()
NP.Parent = game.Workspace
NP.Position = Vector3.new(Saved_Part.Position.X + 5, Saved_Part.Position.Y, Saved_Part.Position.Z)
Saved_Part = NP
end
end
end
end
end)
end)
end)