Hello, I have encountered a problem in my script that won’t allow me to continue writing code. I have a local script in StarterPlayerScripts:
local chatService = game:GetService("TextChatService")
local MessageEvent = game.ReplicatedStorage.FetchMessage -- remote event
chatService.OnIncomingMessage = function(message)
MessageEvent:FireServer(game.Players.LocalPlayer, tostring(message.Text))
end
RemoteEvent “FetchMessage” passes the message text to the server script in the ServerScriptService:
local module = require(game.ServerScriptService.Functionality)
local chatService = game:GetService("TextChatService")
local MessageEvent = game.ReplicatedStorage.FetchMessage
local CheckInputForAnswer = function(input, index)
local part = module.Functions.FindIndex(index)
print(part()) -- This is where the error appears, line 51
if input == module.Functions.DecodeData(part():FindFirstChild("Answer").Value) then
return true
else
return false
end
end
MessageEvent.OnServerEvent:Connect(function(player, player2, message)
if player then
if CheckInputForAnswer(message, player2:FindFirstChild("miscValues").StageIndex.Value + 1) == true then -- Line 61
module.Functions.RemoveBorder(player2:FindFirstChild("miscValues").StageIndex.Value + 1)
end
end
end)
The server script uses some functions from the module script, also located in the ServerScriptService:
local tweenService = game:GetService("TweenService")
local Colours = {
Color3.fromRGB(244, 68, 46),
Color3.fromRGB(185, 95, 137),
Color3.fromRGB(76, 224, 210),
Color3.fromRGB(131, 103, 199),
Color3.fromRGB(44, 42, 74),
Color3.fromRGB(69, 203, 133),
Color3.fromRGB(94, 124, 226),
Color3.fromRGB(255, 178, 56),
}
local module = {
Functions = {
DecodeData = function(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r = r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end,
FindIndex = function(index)
local part = function()
for i,v in pairs(workspace.Map.ImageBoards:GetDescendants()) do
if v:IsA("NumberValue") and v.Value == index then
return v.Parent
end
end
end
end,
RemoveBorder = function(index)
local part = function()
for i,v in pairs(workspace.Map.ImageBoards:GetDescendants()) do
if v:IsA("NumberValue") and v.Value == index then
return v.Parent:FindFirstChild("Part")
end
end
end
local randomColour = Colours[math.random(1, #Colours)]
part().Color = randomColour
part().CanCollide = false
part().Star.Enabled = true
local partCurrentSize = part().Size
tweenService:Create(part(), TweenInfo.new(1.5, Enum.EasingStyle.Circular), {Transparency = 1, Size = partCurrentSize + Vector3.new(1.5, 0, 1.5)}):Play()
tweenService:Create(part().SurfaceGui.ImageLabel, TweenInfo.new(1.5, Enum.EasingStyle.Circular), {ImageTransparency = 1}):Play()
part().Correct:Play()
for i,v in pairs(part():GetChildren()) do
if v:IsA("Texture") then
tweenService:Create(v, TweenInfo.new(1.5, Enum.EasingStyle.Circular), {Transparency = 1}):Play()
end
end
wait(1)
part().Star.Enabled = false
end,
},
}
return module
When sending a message to the chat, this errors occurs:
ServerScriptService.Handler:51: attempt to call a nil value - Server - Handler:51
Stack Begin - Studio
Script 'ServerScriptService.Handler', Line 51 - Studio - Handler:51
Script 'ServerScriptService.Handler', Line 61 - Studio - Handler:61
Stack End - Studio
The error occurs in the server script, I’ve marked where exactly. Any help would be appreciated!