It seems like there is something else called Afisho_rankimin in your DB Therefore the function is not getting created. You can try calling your function something else. E.g.
CREATE FUNCTION dbo.Afisho_rankimin1(@emri_rest int)
RETURNS int
AS
BEGIN
Declare @rankimi int
Select @rankimi=dbo.RESTORANTET.Rankimi
From RESTORANTET
Where dbo.RESTORANTET.ID_Rest=@emri_rest
RETURN @rankimi
END
GO
Also note that you have to call this only once, not each time you call the function. After that try calling
SELECT dbo.Afisho_rankimin1(5) AS Rankimi
Join the SQL Course fast, to Learn SQL concepts in detail and get certified.