Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Teleport script isn't working (nil script invalid)?

Everything works except for the Position part

part = script.Parent

part.ClickDetector.MouseClick:connect(function() awesomeBrick = game.Lighting["Awesome Brick"]:clone() awesomeBrick.Parent = game.Workspace awesomeBrick.Position.X = (12.206, 0.5, -104.321) end)

Ignore (nil script invalid) I just put that there because I had a "bad" title

1 comment

0

If you had a bad title, then you should give it more detail. Not spam important scripting words in it.

2 answers

Write it in code blocks please. Anyways, you have to use Vector3 for positions, also the X axis only uses one line. If you're looking to modify the entire position, remove the ".X". I also modified it to be more clean. This should be your final script:

local part = script.Parent

part.ClickDetector.MouseClick:connect(function()
	local awesomeBrick = game.Lighting["Awesome Brick"]:clone()
	awesomeBrick.Parent = workspace
	awesomeBrick.Position = Vector3.new(12.206, 0.5, -104.321)
end)

2 comments

0

Line 6 is wrong on yours.

0

I know, I edited it

You're simply setting the position wrong.

Use a Vector3 set the position of a part.

local part = script.Parent

part.ClickDetector.MouseClick:connect(function() 
	local awesomeBrick = game.Lighting["Awesome Brick"]:clone() 
	awesomeBrick.Parent = game.Workspace 
	awesomeBrick.Position = Vector3.new(12.206, 0.5, -104.321) 
end)
You should also not use Lighting because Lighting is not a storage service and it's annoying. Oh, and when ending an anonymous function you need a ) after the end).

Optional Changes,

Besides not using Lighting, I would suggest setting the part's CFrame instead of it's position. This is so the part is able to be placed under and inside other parts. In your case this might not be necessary, but I think it's useful to learn.

local part = script.Parent

part.ClickDetector.MouseClick:connect(function() 
	local awesomeBrick = game.ServerStorage["Awesome Brick"]:Clone() -- Move the item to SS
	awesomeBrick.Parent = game.Workspace 
	awesomeBrick.CFrame = CFrame.new(12.206, 0.5, -104.321) 
end)
This could be improved upon even more by using WaitForChild, but if you really want to know how, just ask.

Good Luck!

If I helped, please don't forget to accept my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.