Hello ! Here is my problem: a friend helped me make a script of X2 coins with a gamepass except that it gives the X2 coins even without the gamepass. Here is the script:
game.ReplicatedStorage.Events.dest.OnServerEvent:Connect(function(plr, tar)
tar:Destroy()
end)
--Drop Manager
local debris = game:GetService("Debris")
function randomN(num1,num2)
return math.random(num1*1000,num2*1000)/1000
end
function Drop(Tar)
local dropValue = Tar:FindFirstChild("Drop")
if dropValue then
if dropValue.Value > 0 then
end
end
end
game.ReplicatedStorage.Events.drop.OnServerEvent:connect(function(plr, Tar, despawnTime)
local dropValue = Tar:FindFirstChild("Drop")
if dropValue then
if dropValue.Value > 2 then
local Give = plr:WaitForChild("leaderstats").Coins -- Change to thing what you want to give when player mined something.
local gamepassId = 7226231
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,gamepassId) then
Give.Value = Give.Value + dropValue.Value*2
else
Give.Value = Give.Value + dropValue.Value*2
end
end
end
end)
--Damage
function damg(plr, Dur, dmg)
Dur.Value = Dur.Value - dmg
end
game.ReplicatedStorage.Events.damage.OnServerEvent:connect(damg)````
game.ReplicatedStorage.Events.dest.OnServerEvent:Connect(function(plr, tar)
tar:Destroy()
end)
--Drop Manager
local debris = game:GetService("Debris")
function randomN(num1,num2)
return math.random(num1*1000,num2*1000)/1000
end
function Drop(Tar)
local dropValue = Tar:FindFirstChild("Drop")
if dropValue then
if dropValue.Value > 0 then
end
end
end
game.ReplicatedStorage.Events.drop.OnServerEvent:connect(function(plr, Tar, despawnTime)
local dropValue = Tar:FindFirstChild("Drop")
if dropValue then
if dropValue.Value > 2 then
local Give = plr:WaitForChild("leaderstats").Coins -- Change to thing what you want to give when player mined something.
local gamepassId = 7226231
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,gamepassId) then
Give.Value = Give.Value + dropValue.Value*2
else
Give.Value = Give.Value + dropValue.Value
end
end
end
end)
--Damage
function damg(plr, Dur, dmg)
Dur.Value = Dur.Value - dmg
end
game.ReplicatedStorage.Events.damage.OnServerEvent:connect(damg)````
This opens up a gateway which would let exploiters delete any object in your game without any hassle! I don’t have the context of what this is used for, but you should really have this handled server-side instead.
function Drop(Tar)
local dropValue = Tar:FindFirstChild("Drop")
if dropValue then
if dropValue.Value > 0 then
end
end
end
This code serves no purpose whatsoever. It doesn’t return anything or change anything. so you should probably just scrap it unless you had some other plans.
And, for checking if you want to see if the player owns the gamepass or not, you should have the game create a BoolValue under the player named “Owns(gamepass name)”, and perform the UserOwnsGamePassAsync only once, to set this value. Then, when you need to find out if they own the gamepass later when determining if they get the 2x coins or not, just have the script refer to that BoolValue.
This will make your code a lot more efficient. One more thing that, didn’t make much sense, was when you tried getting “dropValue.Value.gamepassId” on Line 29. You might want to change it to just “Give.Value = Give.Value + dropValue.Value”