I'm trying to build a surface GUI voting system where on other guys you can vote and the votes appear on one big GUI. For some reason, it's not working can anyone explain as to why?

This is the local script in the frame

local pass = game.ReplicatedStorage.Pass
local fail = game.ReplicatedStorage.Fail
local vote = game.ReplicatedStorage.Vote
local chosen

script.Parent.passbutton.MouseButton1Click:Connect(function()
	if chosen ~= "pass" then
		game.ReplicatedStorage.Vote:FireServer(chosen, "pass")
		chosen = "pass"
	end
end)


script.Parent.failbutton.MouseButton1Click:Connect(function()
	if chosen ~= "fail" then
		game.ReplicatedStorage.Vote:FireServer(chosen, "fail")
		chosen = "fail"
	end
end)


while wait() do
	workspace.VotingSystem.MainSystem.SurfaceGui.Frame.Visible = true
	workspace.VotingSystem.MainSystem.SurfaceGui.Frame["Pass Votes"].Text = pass.Value .. " Votes"
	workspace.VotingSystem.MainSystem.SurfaceGui.Frame["Fail Votes"].Text = fail.Value .. " Votes"
end

and this is the script in ServerScriptService

game.ReplicatedStorage.Vote.OnServerEvent:Connect(function(player, previous, chosen)
	local votes = game.ReplicatedStorage[chosen]
	votes.Value = votes.Value + 1
	if previous ~= nil then
		local prev = game.ReplicatedStorage[previous]
		prev.Value = prev.Value - 1
	end
end)

I picked out something from the output.

Attempt to connect failed: Passed value is not a function

1 comment

0

If its a surface gui, as long as you want the same thing for all players, you can just make it a normal script