So, before I tried preventing exploiters and using a different way of getting services instead of doing something like "game.Lighting" and instead "game:GetService("Lighting")" my gamepass used to give me a tool. What would happen is, you would go up to this shopkeeper get the gamepass tool and that's about it. Except it doesn't do that anymore, it still prints saying I have the gamepass every time I get the tool but it acts as if it doesn't fire the remote event and the server doesn't catch it. I honestly have no idea what to do so please help!
What's supposed to happen: You buy gamepass tool, if you had it. It would print saying "You have the gamepass" then the script would fire a remote event to a server script that's supposed to catch it and then give you the tool.
What happened instead: It would print that I had it but it didn't do anything else.
What seemed to cause this: Changing the scripts to instead use "game:GetService" instead of doing "game.Service" in order to prevent SOME exploiters. Plus good practice.
Local Buy Script
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local SoundService = game:GetService("SoundService")
local MarketPlaceService = game:GetService("MarketplaceService")
local ChaChing = script.ChaChing
local portid = 18564612
Replicated.ChaChing.OnClientEvent:Connect(function()
SoundService:PlayLocalSound(ChaChing)
end)
script.parent.SCoil.BuySpeedCoil.MouseButton1Click:Connect(function() -- buying sc
Replicated.BuySC:FireServer()
end) -- Code ends
Replicated.BuySC.OnClientEvent:Connect(function()
player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed - 19 -- Minus your walkspeed
end)
script.parent.TTracker.BuyTracker.MouseButton1Click:Connect(function() -- Buying a FT
Replicated.BuyTracker:FireServer()
end) -- Code ends
script.parent.Flashlight.BuyFlash.MouseButton1Click:Connect(function() -- Buying a FT
Replicated.BuyF:FireServer()
end) -- Code ends
script.parent.HealingCoil.BuyHealCoil.MouseButton1Click:Connect(function()
Replicated.BuyHealingCoil:FireServer()
end)
script.parent.Ultra.BuyUltra.MouseButton1Click:Connect(function()
Replicated.BuyUltra:FireServer()
end)
Replicated.BuyUltra.OnClientEvent:Connect(function()
player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed - 25
player.Character.Humanoid.JumpHeight = player.Character.Humanoid.JumpHeight - 5
end)
script.parent.PortShop.BuyPortShop.MouseButton1Click:Connect(function()
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, portid) then
Replicated.BuyPort:FireServer()
print("Player has Portable Shop gamepass!")
else
MarketPlaceService:PromptGamePassPurchase(player, portid)
print("Prompted player to buy portable shop gamepass.")
end
end)
Normal Buy Script
local Items = game.StarterGui.CryptoShop.Items
local Replicate = game:GetService("ReplicatedStorage")
local MarketPlaceService = game:GetService("MarketplaceService")
local ChaChing = Replicate.ChaChing
local portid = 18564612
-- There was more code like the one below but in order to stay below 10000 characters some code must be deleted.
Replicate.BuyHealingCoil.OnServerEvent:Connect(function(player) -- Buying a FT
local CryptoShop = player.PlayerGui.CryptoShop
local Healing = CryptoShop.Frame.HealingCoil
local PlayerItems = player.Items
local leaderstats = player.leaderstats
if PlayerItems.RegenCoil.Value == 1 and Healing.BuyHealCoil.Text == "Buy for 20 Floors" then -- Checks if the player has reset and broke the gui, this resets it.
Healing.BuyHealCoil.Text = "Unequip" -- Changing text to unequip
Items.RegenCoil:Clone().Parent = player.Backpack
ChaChing:FireClient(player)
return
end
if leaderstats.Floors.Value >= 20 and PlayerItems.RegenCoil.Value == 0 then -- Checks if you have enough to buy the tool
Healing.BuyHealCoil.Text = "Unequip" -- Changing text to unequip
PlayerItems.RegenCoil.Value = 1 -- Changes the value so that the game knows you own it
Items.RegenCoil:Clone().Parent = player.Backpack -- Fires the nonlocal version of the script so you get the tool
ChaChing:FireClient(player)
elseif leaderstats.Floors.Value <= 20 and PlayerItems.RegenCoil.Value == 0 then -- You don't have enough for the tool
Healing.BuyHealCoil.Text = "Not Enough Floors" -- Says that you don't have enough
wait(1.5) -- Waits so people can read the text
Healing.BuyHealCoil.Text = "Buy for 20 Floors" -- Changes back to normal
elseif Healing.BuyHealCoil.Text == "Unequip" then -- Checks if you have the weapon equipped and if you don't, runs the code below
if player.Backpack:FindFirstChild("RegenCoil") then -- Looks for the tool in your backpack, if you have it then it runs the code below
player.Backpack.RegenCoil:Destroy() -- Destroys the tool in your backpack
else -- If the code above is false and tool isn't in your backpack then the code below is ran
if player.Character:FindFirstChild("RegenCoil") then -- Checks for the tool in your hand, if you have then code below is ran. If not, the remotevent below is fired and then you can equip the tool again.
player.Character.RegenCoil:Destroy() -- Destroys the tool in your hand
end
end -- Fires the nonlocal version of the script to unequip your tool
Healing.BuyHealCoil.Text = "Equip" -- Changes text
elseif Healing.BuyHealCoil.Text == "Equip" then -- Checks if the text is Equip
Healing.BuyHealCoil.Text = "Unequip" -- Turns text to Unequip
Items.RegenCoil:Clone().Parent = player.Backpack -- Fires the nonlocal version of the script to equip your tool
end
end) -- Code ends
Replicate.BuyPort.OnServerEvent:Connect(function(player) -- Buying a FT
local CryptoShop = player.PlayerGui.CryptoShop
local Port = CryptoShop.Frame.PortShop
local PlayerItems = player.Items
local leaderstats = player.leaderstats
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, portid) then
if Port.BuyPortShop.Text == "Buy for 75 Robux" then
Port.BuyPortShop.Text = "Unequip"
Items.PortableShop:Clone().Parent = player.Backpack
ChaChing:FireClient(player)
elseif Port.BuyPortShop.Text == "Unequip" then
Port.BuyPortShop.Text = "Equip"
if player.Backpack:FindFirstChild("PortableShop") then -- Looks for the tool in your backpack, if you have it then it runs the code below
player.Backpack.PortableShop:Destroy() -- Destroys the tool in your backpack
else -- If the code above is false and tool isn't in your backpack then the code below is ran
if player.Character:FindFirstChild("PortableShop") then -- Checks for the tool in your hand, if you have then code below is ran. If not, the remotevent below is fired and then you can equip the tool again.
player.Character.PortableShop:Destroy() -- Destroys the tool in your hand
end
end
elseif Port.BuyPortShop.Text == "Equip" then
Port.BuyPortShop.Text = "Unequip"
Items.PortableShop:Clone().Parent = player.Backpack
end
else
player:Kick("Please don't use exploits to get gamepass items for free, it ruins the game for other players that buy the gamepass fairly or don't have it. Please buy the gamepass if you wish to use the item. If you continue this, you may be banned.")
end
end) -- Code ends
Replicate.BuyUltra.OnServerEvent:Connect(function(player)
local CryptoShop = player.PlayerGui.CryptoShop
local Ultra = CryptoShop.Frame.Ultra
local PlayerItems = player.Items
local leaderstats = player.leaderstats
if PlayerItems.UltraCoil.Value == 1 and Ultra.BuyUltra.Text == "Buy for 200 Coins and 100 Floors" then -- Checks if the player has reset and broke the gui, this resets it.
Ultra.BuyUltra.Text = "Unequip" -- Changing text to unequip
Items.UltraCoil:Clone().Parent = player.Backpack
ChaChing:FireClient(player)
return
end
if leaderstats.Floors.Value >= 50 and leaderstats.Coins.Value >= 200 and PlayerItems.UltraCoil.Value == 0 then -- Checks if you have enough to buy the tool
Ultra.BuyUltra.Text = "Unequip" -- Changing text to unequip
PlayerItems.UltraCoil.Value = 1 -- Changes the value so that the game knows you own it
Items.UltraCoil:Clone().Parent = player.Backpack -- Fires the nonlocal version of the script so you get the tool
ChaChing:FireClient(player)
elseif leaderstats.Floors.Value <= 50 and PlayerItems.UltraCoil.Value == 0 or leaderstats.Coins.Value <= 200 and PlayerItems.UltraCoil.Value == 0 then -- You don't have enough for the tool
Ultra.BuyUltra.Text = "Not Enough Floors and Coins" -- Says that you don't have enough
wait(1.5) -- Waits so people can read the text
Ultra.BuyUltra.Text = "Buy for 200 Coins and 100 Floors" -- Changes back to normal
elseif Ultra.BuyUltra.Text == "Unequip" then -- Checks if you have the weapon equipped and if you don't, runs the code below
if player.Backpack:FindFirstChild("UltraCoil") then -- Looks for the tool in your backpack, if you have it then it runs the code below
player.Backpack.UltraCoil:Destroy() -- Destroys the tool in your backpack
else -- If the code above is false and tool isn't in your backpack then the code below is ran
if player.Character:FindFirstChild("UltraCoil") then -- Checks for the tool in your hand, if you have then code below is ran. If not, the remotevent below is fired and then you can equip the tool again.
player.Character.UltraCoil:Destroy() -- Destroys the tool in your hand
Replicate.BuyUltra:FireClient(player)
end
end -- Fires the nonlocal version of the script to unequip your tool
Ultra.BuyUltra.Text = "Equip" -- Changes text
elseif Ultra.BuyUltra.Text == "Equip" then -- Checks if the text is Equip
Ultra.BuyUltra.Text = "Unequip" -- Turns text to Unequip
Items.UltraCoil:Clone().Parent = player.Backpack -- Fires the nonlocal version of the script to equip your tool
end
end) -- Code ends
