Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

There shows up a error when I click a button W/ Filtering enabled?

Hi, I know that the title is confusing but I am making a Dealership and I have a button that the text is "Special Vehicles". When you click it, it will ask you for a gamepass or if you have one a script will execute.

It says the error is in line 8 in the Script

This is the error: "12:17:18.683 - Unable to cast Instance to int"

Here is the code for the local script:

local player = game:GetService('Players').LocalPlayer
local gui = player:WaitForChild("PlayerGui"):WaitForChild("DealershipGUI")
local button = gui:WaitForChild("CategoryContainer").SpecialVeh
local hasSpecialPass = game:GetService('ReplicatedStorage'):WaitForChild("hasSpecialGamepass")

button.MouseButton1Click:connect(function()
	hasSpecialPass:FireServer()
end)

Here is the code for the script:

local hasSpecialPass = game:GetService('ReplicatedStorage'):WaitForChild("hasSpecialGamepass")
local GamepassId = 1186864857
local GamePassService = game:GetService('GamePassService')

hasSpecialPass.OnServerEvent:connect(function(player)
	local gui = player:WaitForChild("PlayerGui"):WaitForChild("DealershipGUI")
	local button = gui:WaitForChild("CategoryContainer").SpecialVeh
	if GamePassService:PlayerHasPass(GamepassId, player) then
		print("hi")
	end
end)

1 answer

✓ Accepted answer
local hasSpecialPass = game:GetService('ReplicatedStorage'):WaitForChild("hasSpecialGamepass")
local id = 1186864857
local GamePassService = game:GetService('GamePassService')

hasSpecialPass.OnServerEvent:connect(function(player)
    local gui = player:WaitForChild("PlayerGui"):WaitForChild("DealershipGUI")
    local button = gui:WaitForChild("CategoryContainer").SpecialVeh
    if GamePassService:PlayerHasPass(player, id) then
        print("hi")
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.