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)
function
s 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
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