Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Error in script function: Appears as endend?

Asked by
Yuyoni 3
7 years ago

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
0
endend in your script isn't a thing..................................................... head isn't even used num1..num2 will give errors because the dots are unnecessary the name can't be 5 numbers at once, their is no way this script will ever work or do anything, goodluck and have a good time... greatneil80 2647 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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
0
thanks, you have solved my problem. Yuyoni 3 — 7y
0
You should accept his answer though. FiredDusk 1466 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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

Answer this question