I’m working on a script a script with a platform, and when you touch a small part on a side of the platform, another platform is cloned or spawns. This doesn’t work though as the output says “ServerScriptService.Script:9: attempt to perform arithmetic (add) on nil and Vector3.” I’ve tried to fix this by using for loops and bringing all the parts, but even majorly extending the script to an excessive amount hasn’t worked. I’m think this script may require a more advanced kind of script. This script is also for only one of the sides.
local RS = game:GetService("ReplicatedStorage")
local Flooring = RS:WaitForChild("Flooring")
local debounce = false
game.Workspace.Flooring.TouchPart1.Touched:Connect(function()
if debounce == false then
Flooring:Clone()
Flooring.Parent = workspace
local FlooringChildren = Flooring:GetChildren()
FlooringChildren.Position += Vector3.new(0,0,15)
end
end)
Wrote this on mobile so there might be errors but, I think it’s correct, try it out! I did plus 15 because you’re adding 15 to your z plane on your original script.
local Flooring = RS:WaitForChild("Flooring")
Floor:Clone() -- Is not stored in a variable
Instead do
local Flooring = RS:WaitForChild("Flooring")
-- Store Floor:Clone() in variable
local floorClone = Flooring:Clone()
and store it in a variable. Then when you want to change things about the clone you would do stuff like
local Flooring = RS:WaitForChild("Flooring")
-- Store Floor:Clone() in variable
local floorClone = Flooring:Clone()
-- Set Parent of clone
floorClone.Parent = workspace
FlooringChildren is not the Child of the Floor. but an array of children instances of it.
If you want to get the correct Child you need to use Flooring:FindFirstChild("Child_Name"), Flooring.Child_Name or Flooring:GetChildren()[1]
also on another thing you have to have a variable for Floor:Clone()
while this solves the error issue, I do not know much about what You are trying to achieve
Do any of you know how I can apply addition to MoveTo? Like do you know how I can add position each time a function runs each time I use MoveTo. (I made it infinite lets go!!!)