When i make a function, does it only work in the script?

not sure but i made a function that changes brick color and it worked in that script then i wrote this function is called “color()”

while true do
function color()
end
end

however i wrote this code in a seperate script, both codes are in the workspace if that changes anything.

The way you have your code set up right now (a function in one script and a while-loop trying to call it in another) does not work because functions are local to each script. Also, to call a function, you simply write the function name followed by (). If you move the while-loop into the script where the color function is defined, then this should work. Example:

function color()
    --The code for what color should do goes here
end

while true do
    color()
end

(And don’t forget to add a wait() somewhere in the loop or function!)