Help with gamepass error

Hello, so recently I played my game and I looked in the dev console and found this error:


How can I fix this?

Code:

local OnPad = {}
local mps = game:GetService("MarketplaceService")
local gamepasses = require(game.ReplicatedStorage.GiftGamepassReplicatedStorage:WaitForChild("GiftableGamepasses"))
local jumpId = gamepasses[2][1]


script.Parent.Touched:Connect(function(Hit)
	local Character = Hit.Parent
	if Character then
		local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
		local Humanoid = Character:FindFirstChild("Humanoid")
		local ownsJumpBoost = mps:UserOwnsGamePassAsync(Player.UserId, jumpId)

		if Humanoid and Player then
			if not OnPad[Player] then
				OnPad[Player] = true
				Humanoid.JumpPower = workspace.Gravity
				wait()
				Humanoid.Jump = true
				wait(0.5)
				if ownsJumpBoost then
					Humanoid.JumpPower = 78
				else
					Humanoid.JumpPower = 52
				end
				OnPad[Player] = false
			end
		end
	end
end)
2 Likes

In your touched script, you are not checking if the hit is in the player. For ex, you might have a object touching it, and it thinks the character is the parent of the random object, but when you use :GetPlayerFromCharacter' there is no player.

Fix this by adding this in between the touched event and before the local Character variable

if Hit.Parent:FindFirstChild('Humanoid') then


end

Then i add the rest of the code inside that if statement correct?

1 Like

Yes, put all your code inside of the if statement and tell me if it works.

1 Like

Works thank you for helping me out

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.