Hi I have this block of code that manages the purchases in the game so there’s a infinite Jump funtion when a player buys it gives the player infinite Jumps here’s that piece of code `function server.functions.InfiniteJump(player: Player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character.Humanoid
productPurchased:FireClient(player, "InfiniteJump")
local UIS = game:GetService("UserInputService")
local LeftFoot = character:FindFirstChild("LeftFoot")
local Jumping = Enum.HumanoidStateType.Jumping;
local falling = Enum.HumanoidStateType.Freefall;
local landed = Enum.HumanoidStateType.Landed;
local DoubleJump = false;
local JumpCount = 0;
humanoid.StateChanged:Connect(function(old,new)
if(old == falling) and (new == landed) then
DoubleJump = false;
JumpCount = 0;
return
end
if(old == falling) and (new == landed) then
DoubleJump = true;
JumpCount = JumpCount + 1
end
end)
UIS.InputBegan:Connect(function(input, gpe)
if gpe then
return
end
if input.KeyCode == Enum.KeyCode.Space then
if(DoubleJump and JumpCount < 5) then
DoubleJump = true;
humanoid:ChangeState(Jumping);
end
end
end)
end`
Now the problem is that when I write the whole functionality of the Jump script nothing changes the player doesnt infinetly jump and there’s no errors in output,
I’ve tried multiple stuff like writing it as a module, and joining it in the same purchases handler script but nothing here’s the whole code if someone may help thank you `-- // Types ( lazy as shit )
type receipt = {PlayerId: number; ProductId: number}
– // Services
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
– // Replicated
local remotes = ReplicatedStorage.Shared.Remotes
local clientRequestTeleport = remotes.RequestClientTeleport
local clientInifiniteJump = remotes.ClientInifiniteJump
local requestUserOwnsProduct = remotes.RequestUserOwnsProduct
local productPurchased = remotes.ProductPurchased
– // Modules
local ids = require(ReplicatedStorage.Shared.Identification)
local ClientHandler = require(ReplicatedStorage.Shared.ClientHanlder)
– // Events
– // Variables
local server = {}
server.functions = {}
server.cache = {}
local jumppower = 50*4
----| Private Functions |----
local function findPlayer(name: string, useDisplay: boolean): Player | nil
name = string.lower(name)
local found: Player
for _, v: Player in Players:GetPlayers() do
if string.lower(v.Name) ~= name or string.lower(v.DisplayName) ~= name then continue end
found = v
break
end
return found
end
local function findNameById(find: number): string
local found: string
for name: string, id: number in ids do
if id == find then found = name; break end
end
return found
end
function server.functions.FourTimeJumpPower(player: Player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character.Humanoid
humanoid.JumpPower = jumppower
productPurchased:FireClient(player, "FourTimeJumpPower")
end
function server.functions.TeleportToFriend(player: Player)
productPurchased:FireClient(player, "TeleportToFriend")
end
function server.functions.SkipStage(player: Player)
local leaderstats: Folder = player:FindFirstChild("leaderstats")
local stage: IntValue = leaderstats.Stage
stage.Value += 3
player:LoadCharacter()
end
function server.functions.InfiniteJump(player: Player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character.Humanoid
productPurchased:FireClient(player, "InfiniteJump")
local UIS = game:GetService("UserInputService")
local LeftFoot = character:FindFirstChild("LeftFoot")
local Jumping = Enum.HumanoidStateType.Jumping;
local falling = Enum.HumanoidStateType.Freefall;
local landed = Enum.HumanoidStateType.Landed;
local DoubleJump = false;
local JumpCount = 0;
humanoid.StateChanged:Connect(function(old,new)
if(old == falling) and (new == landed) then
DoubleJump = false;
JumpCount = 0;
return
end
if(old == falling) and (new == landed) then
DoubleJump = true;
JumpCount = JumpCount + 1
end
end)
UIS.InputBegan:Connect(function(input, gpe)
if gpe then
return
end
if input.KeyCode == Enum.KeyCode.Space then
if(DoubleJump and JumpCount < 5) then
DoubleJump = true;
humanoid:ChangeState(Jumping);
end
end
end)
end
----| Main Code |----
Players.PlayerAdded:Connect(function(player: Player)
--> Add cache
server.cache[player] = {}
--> Check for gamepasses
--for name: string, id: number in ids do
-- if MarketplaceService:UserOwnsGamePassAsync(player.UserId, id) then
-- server.functions[name]()
-- end
--end
end)
clientRequestTeleport.OnServerEvent:Connect(function(player: Player, other: string)
if not other then return end
--> check if he owns product
if not server.cache[player][ids.TeleportToFriend] then
warn(`Server request -> Teleport to player denied. Reason: User doesn't own product.`)
MarketplaceService:PromptPurchase(player, ids.TeleportToFriend)
end
--> Find player simply
local found: Player = Players:FindFirstChild(other)
--> If not found then check for caps mistakes
if not found then
found = findPlayer(other, true)
if not found then warn(`Server request -> Teleport player[{player.Name}] to player[{other}] failed. `) return end
end
--> Teleport player to other player
player.Character:PivotTo(found.Character:GetPivot())
end)
→ Request if user owns product
requestUserOwnsProduct.OnServerInvoke = function(player: Player, id: number)
if not id then return nil end
local owns = server.cache[player][id]
if not owns then
return false
end
return owns
end
→ Process Receipt
MarketplaceService.ProcessReceipt = function(receiptInfo: receipt)
local userId = receiptInfo.PlayerId
local product = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
--> Return unsuccesful pruchase
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
--> Give player what they bought
local handler = server.functions[findNameById(product)]
local success, result = pcall(handler, player)
--> Check for status
if success then
--> Add purchase to cache
server.cache[player][product] = true
--> Granted purchase reward
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn(`Server purcahse request -> Failed to purchase product[{product}]. Error code: {result}.`)
end
--> Return failed
return Enum.ProductPurchaseDecision.NotProcessedYet
end`