Im trying to make it so if you own the gamepass a certain local script located in StarterPlayerScripts run. Inside ServerScriptService I have a script that detects when someone joins and then there is a function. I have tried putting the local script into this script, but then i ran into a problem which made it unusable, I think it has to be inside StarterPlayerScripts.
So my question is, is it possible to make a script only run if they own a gamepass?
Here is the script inside ServerScriptService.
local GamepassID = 1234567
game.Players.PlayerAdded:Connect(function(plr)
local owned = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,GamepassID)
local function Check()
if not plr:WaitForChild("PlayerGui"):FindFirstChild(script:GetChildren()[1]:Clone().Name) and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,GamepassID) then
script:GetChildren()[1]:Clone().Parent = plr:WaitForChild("PlayerGui")
end
end
plr.CharacterAdded:Connect(Check)
Check()
end)
Here is the local script, its a double jump script.
local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.08
local DOUBLE_JUMP_POWER_MULTIPLIER = 1.2
function onJumpRequest()
if not character or not humanoid or not character:IsDescendantOf(workspace) or humanoid:GetState() == Enum.HumanoidStateType.Dead then
print ("yes")
end
if canDoubleJump and not hasDoubleJumped then
hasDoubleJumped = true
humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end
local function characterAdded(newCharacter)
character = newCharacter
humanoid = newCharacter:WaitForChild("Humanoid")
hasDoubleJumped = false
canDoubleJump = false
oldPower = humanoid.JumpPower
humanoid.StateChanged:connect(function(old, new)
if new == Enum.HumanoidStateType.Landed then
canDoubleJump = false
hasDoubleJumped = false
humanoid.JumpPower = oldPower
elseif new == Enum.HumanoidStateType.Freefall then
wait(TIME_BETWEEN_JUMPS)
canDoubleJump = true
end
end)
end
if localPlayer.Character then
characterAdded(localPlayer.Character)
end
localPlayer.CharacterAdded:connect(characterAdded)
UserInputService.JumpRequest:connect(onJumpRequest)
Thanks for your help!

2 comments
The link doesnt work... sadly
Here is the working link: https://www.youtube.com/watch?v=d3Ke3VRaSCk