Why wont my gamepass gear giver work properly?
--In my game,I want to have a gamepass that lets you get a gun by the click of a button. My script doesn't work, however, and lets me get the gun whether I have the gamepass or not. Does anyone see any problems with the script?
repeat wait() until game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UserInputService = game:GetService("UserInputService")
local MarketPlaceService = game:GetService("MarketplaceService")
local IdGamepass = 8238123
local RemoteEvent = game.ReplicatedStorage.GamepassEvent
local HasGamepass = false
RemoteEvent.OnClientEvent:Connect(function(isAllowed)
if isAllowed then
HasGamepass = true
else
HasGamepass = false
end
end)
script.Parent.MouseButton1Click:connect(function()
if HasGamepass = true then
local tool = script.Parent.HyperlaserGun:Clone()
tool.Parent = Player.Backpack
end
end)
wait(1)
RemoteEvent:FireServer(IdGamepass)