so i typed a simple function. the function i was using the function onclick() , but it appeared at the end function that instead of end it said "endend" anyone know why? Here's the script as it follows
function onClick() -- start function endend local Num1 = math.random(1,9) local Num2 = math.random(1,9) local Num3 = math.random(1,9) local Num4 = math.random(1,9) local Num5 = math.random(1,9) local number = Num1 .. Num2 .. Num3 .. Num4 .. Num5 Model.Name = number endend local Head = script.Parent -- our part named Head local Model = script.Parent -- the model containing the part endend
Okay there is a lot wrong here.
Firstly I have no idea what you are doing with endend. You should use one 'end'.
Next you don't end a function on the next line of a function... You put the end at the bottom under Model.Name = number, again use End once.
Next when defining variables you should define them at the top of the function or before you use code to do something with that variable.
Lastly, if you have 1 function, you only need 1 end statement.
function onClick() -- start function local Head = script.Parent -- our part named Head local Model = script.Parent -- the model containing the part local Num1 = math.random(1,9) local Num2 = math.random(1,9) local Num3 = math.random(1,9) local Num4 = math.random(1,9) local Num5 = math.random(1,9) local number = Num1 .. Num2 .. Num3 .. Num4 .. Num5 Model.Name = number end
I'm gonna refer to what Guest said, here is some more code but alot more small.
function onClick() -- start function local Head = script.Parent -- our part named Head local Model = script.Parent -- the model containing the part math.randomseed(os.time()) local Ran = math.random local number = Ran(1,9)..Ran(1,9)..Ran(1,9)..Ran(1,9)..Ran(1,9) Model.Name = number end