I was doing a map voting tutorial and I'm trying to change it to where instead of it being parts on the floor that you step on to vote I was trying to change it to where you vote with a button.

here is the script:

--Player--
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local gui = player:WaitForChild("PlayerGui")
local ui= gui:WaitForChild("ui")
 
--Assets--
local rep = game.ReplicatedStorage
local assets = rep.Assets

--Maps--
local maps = assets.Maps

--Signals--
local signals = assets.Signals
local event = signals.Event
local fevent = signals.FEvent

--Game Variables--
local Game = game.StarterGui.Game
local stats = Game.Stats

--Static Variables--
local vars = {
	currentVote=nil;
	services={};
}

--Primary Events--
event.OnClientEvent:connect(function(variables)
	if variables.reason == "startVoting" then
		table.insert(vars.services, game:GetService("RunService").RenderStepped:connect(function()
			local ray = Ray.new(char.PrimaryPart.CFrame.p, Vector3.new(0.-1000.0))
			local object = workspace:findPartOnRay(ray, char, false, false)
			if object and object.Name:match("VotingButton") then
				local votingGUINum = tonumber(object.Name:match("%d+"))
				if vars.currentVote==nil then
					vars.currentVote = votingGUINum
					event:FireServer({reason="voteOnMap"; itemNum=votingGUINum;})
				elseif vars.currentVote~=votingGUINum then
					vars.currentVote = votingGUINum
					event:FireServer({reason="voteOnMap"; itemNum=votingGUINum;})
				end
			elseif vars.currentVote~=nil then
				vars.currentVote=nil
				event:FireServer({reason="removeFromVote"})
			end
		end))
	elseif variables.reason == "endVoting" then
		for a,b in pairs(vars.services) do
			b:disconnect()
		end
		vars.services= {}
	end
end)

on line 33 and 34 the:

		local ray = Ray.new(char.PrimaryPart.CFrame.p, Vector3.new(0.-1000.0))
		local object = workspace:findPartOnRay(ray, char, false, false)

I think this is the issue, this is what detects parts on the map to change text on the part's surface GUI, I changed the parts into GUI's and put them into the StarterGUI with a button to vote, it doesn't seem to work but there is no output error, so I am assuming that this is the error.

If you know how to fix this please reply ! thank you.