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

How Would i make a x2 leaderstat gamepass? and with each click of the tool?

*How Would i make a 2 leaderstat gamepass? and with each click of the tool?

Basicallyy... i want to make a script where it will * your money (Halopower) on each click of the tool but you have to own a gamepass for it to work i have tried using remote events to use it but i dont know...

module script inside serverscriptservice (under a folder called x2 Gamepass)

local module = {}
local replicatedstorage = game:GetService("ReplicatedStorage")

function module.x2()
replicatedstorage:WaitForChild("ClearHalopower"):FireServer()
 --[[ calling the event ClearHalopower to distract exploiters from finding it bc i have no idea how to prevent exploiters from using it
]]
end



return module

normal script inside serverscriptservice (also under a folder called x2 Gamepass)

local id = script.Parent.GamepassId
local marketservice = game:GetService("MarketplaceService")
local module = require(script.Parent:WaitForChild("ModuleScript"))

marketservice.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and id == ido then
	module.x2()
end
end)

game.Players.PlayerAdded:Connect(function(plr)
if marketservice:UserOwnsGamePassAsync(plr.UserId,id) then
	module.x2()				
end
	end)

remotes script in Serverscriptservice (under no folder)

local repStore = game:GetService("ReplicatedStorage")
local remData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local sra = 10000
local debounceVal = 1
local X = repStore.Remotes:WaitForChild("ClearHalopower").OnServerEvent
	
	
	





repStore.Remotes.Lift.OnServerEvent:Connect(function(player)
	
	if not remData:FindFirstChild(player.Name) then return "NoFolder" end 
	
	local debounce = remData[player.Name].Debounce
	
	if not debounce.Value then 
		
		debounce.Value = true 
		
		player.leaderstats.Halopower.Value = player.leaderstats.Halopower.Value + 5 * (player.leaderstats.Rebirths.Value + 1)
		
		wait(debounceVal)
		
		debounce.Value = false
		
	end
end)

repStore.Remotes.LiftMolten.OnServerEvent:Connect(function(player)
	
	if not remData:FindFirstChild(player.Name) then return "NoFolder" end 
	
	local debounce = remData[player.Name].Debounce
	
	if not debounce.Value then 
		
		debounce.Value = true 
		
		player.leaderstats.Halopower.Value = player.leaderstats.Halopower.Value + 10 * (player.leaderstats.Rebirths.Value + 1)
		
		wait(debounceVal)
		
		debounce.Value = false
		
	end
end)


repStore.Remotes.LiftIce.OnServerEvent:Connect(function(player)
	
	if not remData:FindFirstChild(player.Name) then return "NoFolder" end 
	
	local debounce = remData[player.Name].Debounce
	
	if not debounce.Value then 
		
		debounce.Value = true 
		
		player.leaderstats.Halopower.Value = player.leaderstats.Halopower.Value + 25 * (player.leaderstats.Rebirths.Value + 1)
		
		wait(debounceVal)
		
		debounce.Value = false
		
	end
end)


repStore.Remotes.ClearTools.OnServerEvent:Connect(function(player)
	
	if not remData:FindFirstChild(player.Name) then return "NoFolder" end 
	
	local debounce = remData[player.Name].Debounce
	
	if not debounce.Value then 
		
		debounce.Value = true 
		
		player.leaderstats.Halopower.Value = player.leaderstats.Halopower.Value + 10000 * (player.leaderstats.Rebirths.Value + 1)
		player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + 1
		
		wait(0.001)
		
		debounce.Value = false
		
	end
end)



repStore.Remotes.Rebirth.OnServerInvoke = function(player)
	if not remData:FindFirstChild(player.Name) then return "NoFolder" end 
	
	local rebirths = player.leaderstats.Rebirths
	if player.leaderstats.Halopower.Value >= (math.floor((sra + (rebirths.Value) * math.sqrt(50000000)))) 
	then rebirths.Value = rebirths.Value + 1
		player.leaderstats.Halopower.Value = 0
		
		player:LoadCharacter()
		
		return true
		
		else return "NotEnoughHalopower"
		
	end
	
end



the local X is my attempt at doing it but i cant get it to work so i reverted the script i have no idea how to do this so please if you can fix it

                                 Thanks
                                             - Joe Engo (aka mightbeahaxxer)

1 answer

Also i changed the Normal Script (under the folder called x2 Gamepass) to

local id = script.Parent.GamepassId
local marketservice = game:GetService("MarketplaceService")
local module = require(script.Parent:WaitForChild("ModuleScript"))

game.Players.PlayerAdded:Connect(function(plr)
if marketservice:UserOwnsGamePassAsync(plr.UserId,id) then
	module.x2()				
end
	end)

since i want them to restart there game before they can use it

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