Roblox attempt to call a userdata value errror in my code. why?
Asked by
5 years ago Edited 5 years ago
So, I followed a tutorial on how to make a Roblox map voting system but I keep getting this error "attempt to call a userdata value" this happens on these two lines of code:
1 | table.insert(vars.services, game( "GetService" , "RunService" ).RenderStepped:connect( function () |
and
1 | game( "GetService" , "RunService" ).RenderStepped:connect( function () |
If anybody knows how to fix this I would greatly appreciate it! it's the only error I am currently getting. Thanks :)
Whole script:
02 | local player = game.Players.LocalPlayer |
03 | local char = player.Character or player.CharacterAdded:wait() |
04 | local gui = player:WaitForChild( "PlayerGui" ) |
05 | local ui = gui:WaitForChild( "ui" ) |
08 | local rep = game.ReplicatedStorage |
09 | local assets = rep.Assets |
12 | local maps = assets.Maps |
15 | local signals = assets.Signals |
16 | local event = signals.Event |
17 | local fevent = signals.FEvent |
20 | local Game = workspace.Game |
21 | local stats = Game.Stats |
30 | event.OnClientEvent:connect( function (variables) |
31 | if variables.reason = = "startVoting" then |
32 | table.insert(vars.services, game( "GetService" , "RunService" ).RenderStepped:connect( function () |
33 | local ray = Ray.new(char.PrimaryPart.CFrame.p, Vector 3. new( 0 ,- 1000 , 0 )) |
34 | local object = workspace:FindPartOnRay(ray, char, false , false ) |
35 | if object and object.Name:match( "VotingPad" ) then |
36 | local votingPadNum = tonumber (object.Name:match( "%d+" )) |
37 | if vars.currentVote = = nil then |
38 | vars.currentVote = votingPadNum |
39 | event:FireServer( { reason = "voteOnMap" ; itemNum = votingPadNum; } ) |
40 | elseif vars.currentVote~ = votingPadNum then |
41 | vars.currentVote = votingPadNum |
42 | event:FireServer( { reason = "voteOnMap" ; itemNum = votingPadNum; } ) |
44 | elseif vars.currentVote~ = nil then |
46 | event:FireServer( { reason = "removeFromVote" } ) |
49 | elseif variables.reason = = "endVoting" then |
50 | for a,b in pairs (vars.services) do |
58 | game( "GetService" , "RunService" ).RenderStepped:connect( function () |
59 | ui:WaitForChild( "Title" ).Text = stats.Status.Value |