Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
RootEntry 111
6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
6 years ago
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)
Ad

Answer this question