Heyo New Coder Here. I'm working on a small idea for a game and I need a spawner that spawns a brick on top of another one wherever it may have been moved to. I have been able to get the code to spawn a new brick at 0,0,0 but I cant seem to get it to spawn on an already existing one I have named "Cube". If anyone can help me that would be very much appreciated as I have watched well over 20 videos by now and sourced all of the Roblox forum pages and found nothing to help. Thanks in advanced!
''' lau
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
end)
local input = Enum.KeyCode
if input == Enum.KeyCode.E then
local Cube = game.Workspace:FindFirstChild("Cube")
if not Cube then
print ("Cube was not found")
return
end
end
-- Create the Brick
local brick = Instance.new("Part")
brick.Size = Vector3.new(4, 1, 4)
brick.BrickColor = BrickColor.new("Really red")
--Spawn on Cube
local Cube = game.Workspace:FindFirstChild("Cube")
brick.Position = Cube.Position + Vector3.new(0, 2, 0)
brick.Parent = game.Workspace
''''
** You are now Level 1! **