So I am creating a tool giver system, and there are a remote function and a local script. Whenever you click a button it should invoke the remote function but while doing this the script errors: 19:40:29.649 - ServerScriptService.Tool:19: attempt to compare string with a number.
Please Help -- Yours truly, suspectshot108
Local Script: Broken -- Line.. uhh well whenever u invoke the server.
local EventFolder = game:GetService("ReplicatedStorage").Functions
local RequestTool = EventFolder:WaitForChild("RequestTool")
for _,btn in pairs(script.Parent:GetChildren()) do
if btn:IsA("TextButton") and btn.Name == "Item" then
btn.MouseButton1Click:Connect(function()
local Cost = btn:WaitForChild("Cost").Value
local Name = btn:WaitForChild("Name").Value
RequestTool:InvokeServer(Name,Cost)
end)
end
end
Script: Works Fine -- I think...
--[[
File Name: Tool Request Accepted;
Writen by suspectshot108;
Version: 1.0
--]]
local EventFolder = game:GetService("ReplicatedStorage").Functions
local RequestTool = EventFolder:WaitForChild("RequestTool")
RequestTool.OnServerInvoke = function(Player,Name,Cost)
if Player ~= nil then
if Player.leaderstats and Player.Security then
if Player.leaderstats.Bits and Player.Security.Bits then
if string.match(Player.leaderstats.Bits.Value,Player.Security.Bits.Value) then
local Ls = Player.leaderstats
local Sy = Player.Security
local Tl
local Ne = "Bits"
if Ls[Ne].Value and Sy[Ne].Value >= Cost then
Tl = game:GetService("ReplicatedStorage").Tools[Name]:Clone()
Tl.Parent = Player.Backpack
wait()
Ls[Ne].Value = Ls[Ne].Value - Cost
Sy[Ne].Value = Sy[Ne].Value - Cost
end
else
Player:Kick("Something is wrong with your leaderstats.")
end
end
end
end
end

4 comments
According to the error, the problem is in the server script on line 19. If you look at it closely, it says what script and what line every time it shows an error.
I don't get it...
19:40:29.649 - ServerScriptService.Tool:19: attempt to compare string with a number. "ServerScriptService.Tool" shows what script the problem is in. The number after it is the line number.
Try use IntValue instead of String Value.