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

My Double Jump Button Gamepass isn't Working?

So I have this in a local script in a text button that is in a gui, that is in startergui. The script is supposed make the gui only seeable to the players that own the gamepass and when clicked will give the player a higher jump. It doesn't seem to be working could someone tell me whats wrong?

local player = script.Parent.Parent.Parent.Parent.Parent

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 4916610) then
	script.Parent.MouseButton1Click:connect(function()
		 game:GetService("Players").PlayerAdded:Connect(function(plr) -- :connect is deprecated, use :Connect

    plr.CharacterAdded:Connect(function(char) -- wait for the character! 
        if isAuthenticated(plr.UserId, passId) then
            char.Humanoid.JumpPower = char.Humanoid.JumpPower + 30 
	    end
	end)
else
	script.Parent.Visible = false
end

2 comments

0

"UserId" is spelt wrong on line 3.

0

Dude why do you use player as 50 parents

1 answer

Is this your script? What else are you trying to do?

Try not doing that messy local player = script.Parent.Parent.Parent.Parent.Parent just to find the player. Use game.Players.LocalPlayer but in this case we are not client sided at all.

In a Server Script:

--You can/should set services outside of functions.
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")

local gamePassId = 4916610--Your gamepass id

local guiToGive = script:WaitForChild("ScreenGui") --what ever the location is to the gui

Players.PlayerAdded:Connect(function(player)
	if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then

		--Manage this if I missed something
		player.CharacterAdded:Connect(function(character)
			local gui = guiToGive:Clone()
			gui.Parent = player.PlayerGui
			
			character.Humanoid.JumpPower = character.Humanoid.JumpPower + 30 --probably dont want this hard-coded (make a variable up above).
		end)
	end	
end)

edit: I believe you can use PlayerAdded on client side

1 comment

0

you can use PlayerAdded on the client but it's useless because the player loads before the script runs and once it does the player will have already joined, so it waits for another player instead. And userId is deprecated use UserId

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