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

Error in script function: Appears as endend?

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

1 comment

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...

2 answers

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




2 comments

0

thanks, you have solved my problem.

0

You should accept his answer though.

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

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