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

Why is it asking about a name near it?

mmk so I just started learning how to script. I wanted to make a part named Brick, clone you when you step on it. I made this little script but it keeps saying there's an error and want a name near it or something. Any help?

bool = true
ping = game.Workspace.Player

function
	if bool == false then return end
	bool = false
	ping:clone().parent = Workspace
	wait(4)
	bool = true
end

ping.Touched:connect(clonePlayer)

3 answers

✓ Accepted answer

functions have two forms:

definitions -- where you give a name (and it's a statement):

function myFunc()
	-- stuff
end

anonymous -- where you don't give a name (and it's an expression):

blah = function()

end

Your code looks like neither -- you don't have anything after the function keyword and you at least need ().

The error is telling you expecting a name because it's assuming you mean the first kind of function:

function clonePlayer()
	if bool == false then return end
	..... -- etc
end

You have to use .Parent and not .parent. Names are case-sensitive.

bool is a terrible variable name. Describe what it means! e.g., maybe cloned. Then cloned starts as nil or false and you can say

if cloned then return end
cloned = true

2 comments

0

I was going off the myBool thing of true or false. Bool meaning if the script was false it would go straight to the end. If it was true it would keep going. But I didn't know about the case sensitive stuff, thanks! :)

0

You want your variable names to have meaning. Yes, it's a boolean, but that doesn't tell you anything about what it's for.

Ahh! I fixed it!

ding = true
ping = game.Workspace.Player

function clonePlayer()
	if ding == false then return end
	ding = false
	ping:clone().Parent = Workspace
	wait(4)
	ding = true
end

ping.Touched:connect(clonePlayer)

First I changed the Bool to Ding for a better name I guess. But the name was missing after the function! I forgot clonePlayer()!! Looking at my Lua Learning Book on Amazon and saw I missed it. Thanks guys! I didn't know ROBLOX was case sensitive. :)

Your syntax is a but messed up in the middle try something like this

local newPart = ping:Clone()
newPart.Parent = game.Workspace

3 comments

0

I wanted to make it clone your character. It was named Player in test mode. I'll change some wording and get back to you.

0

if you want to clone the character then that script would look much different

0

This is not necessary. What he had is perfectly acceptable in syntax. He should just use .Parent instead of .parent.

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