I am typing a script that will detect whether or not an items Name matches what the script says, but I repeatedly get this error in the output:
Players.Osamiku.PlayerGui.Client:37: attempt to index nil with 'match'
here is the script, it happens on line 37:
--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
local ScreenGUI = Game.Special.VotingGUIs.ScreenGUI
local Part = ScreenGUI:GetChildren()
--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 = Part
if object and object.Name:match("votingGUI")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)
--Initiate Title Updater
game:GetService("RunService").RenderStepped:connect(function()
ui:WaitForChild("Title").Text = game.StarterGui.Game.Stats.Status.Value
end)
if anyone knows how to solve this, please tell me. Thanks
