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

Keep getting "expected end to close function" even though i dont need one?

So, i have a big chunky script in the serverscriptservice that handles the movement. (my game is an online boardgame).

Around this bit, where i roll the dice and read which face is up, i keep getting an error: Expected end to close function.

Even if i add an extra end, it doesnt work. Here is that peice of code:


local function isLooking(obj1, obj2)
	local p2pVec = (obj2.Position - obj1.Position).unit
	--check for 2 
	local found = isSide(obj1.CFrame.LookVector, p2pVec)
	if found then 
		return 2
	end
	--check for 5
	local found = isSide(-obj1.CFrame.LookVector, p2pVec)
	if found then 
		return 5
	end
	
	--check for 3
	local found = isSide(obj1.CFrame.RightVector, p2pVec)
	if found then 
		return 3
	end
	--check for 4
	local found = isSide(-obj1.CFrame.RightVector, p2pVec)
	if found then 
		return 4
	end
	--check for 6
	local found = isSide(-obj1.CFrame.UpVector, p2pVec)
	if found then
		return 6
	end
	--check for 1
	local found = isSide(obj1.CFrame.UpVector, p2pVec)
	if found then
		return 1
	end
end


local function RollDice()
	local ChangeCameraDice = game:GetService("ReplicatedStorage"):WaitForChild("ChangeCameraDice")
	
	ChangeCameraDice:FireAllClients()
	
	dice.Anchored = false
	local x = rand:NextInteger(-30,30)
	local y = rand:NextInteger(-30,30)
	local z = rand:NextInteger(-30,30)
	
	dice.RotVelocity = Vector3.new(x,y,z)
	wait(3)
	return isLooking(dice, upPartDice) 
	dice.Anchored = true
	dice.Position = originalPos
end

And i can give you the full script if you want it.

1 comment

0

Where does it say "expected end to close function"? Should say something like, "expected end to close function:31" for line 31, etc.

1 answer

This Is My Understanding Of Your Question Hope This Would Fix It IF It Doent Please Dont Leave Any hate Comments also If this Dosent Fixes It Can You Also Tell The Whole Error

local function isLooking(obj1, obj2)
    local p2pVec = (obj2.Position - obj1.Position).unit
    --check for 2 
    local found1 = isSide(obj1.CFrame.LookVector, p2pVec)
    if found1 then 
        return 2
    end
    --check for 5
    local found2 = isSide(-obj1.CFrame.LookVector, p2pVec)
    if found2 then 
        return 5
    end

    --check for 3
    local found3 = isSide(obj1.CFrame.RightVector, p2pVec)
    if found3 then 
        return 3
    end
    --check for 4
    local found4 = isSide(-obj1.CFrame.RightVector, p2pVec)
    if found4 then 
        return 4
    end
    --check for 6
    local found5 = isSide(-obj1.CFrame.UpVector, p2pVec)
    if found5 then
        return 6
    end
    --check for 1
    local found6 = isSide(obj1.CFrame.UpVector, p2pVec)
    if found6 then
        return 1
    end
end

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