I am making a pirate game but I have an error with my ship cloning script you have to press a button to spawn the ships but it does not work I have my ships located in Server storage and keep getting an error like this: Workspace.Regen.Spawn script:7: attempt to index nil with 'Parent' I have no idea why and it says this it also happens with every other script I try pls help:
local Clicker = script.Parent local Object = game.ServerStorage:WaitForChild("smallship") local ObjectSpawn = game.Workspace:WaitForChild("Regen")
script.Parent.ClickDetector.MouseClick:Connect(function() local CloneObject = Object:Clone() CloneObject.Parent = game.Workspace CloneObject.CFrame.position(161, 2.5, -91) end)
Try changing your script to this:
local Clicker = script.Parent local Object = game.ServerStorage:WaitForChild("smallship") local ObjectSpawn = game.Workspace:WaitForChild("Regen") script.Parent.ClickDetector.MouseClick:Connect(function() local CloneObject = Object:Clone() CloneObject.Parent = game.Workspace CloneObject.Position = Vector3.new(161, 2.5, -91) end)
Also if you want to use CFram, you should read a little bit on this article: https://developer.roblox.com/en-us/articles/Understanding-CFrame