Include a standalone, bare-bones rbxl file with only the code you want reviewed.
- Code Review is for reviewing specific parts of your code, and not your whole game.
- Code Review is intended for improving already-working code. If you need help debugging your code, please use Scripting Support.
Provide an overview of:
- What does the code do and what are you not satisfied with?
my code is a simple gamepass check, and if the player owns the gamepass i give them the perk. - What potential improvements have you considered? β maybe use some other checks.
- How (specifically) do you want to improve the code? β i want to know if this is a good way to check for gamepass, and if itβs not the best way i want to know what it is.
local MPS = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(plr)
--\\ Variables \\--
local Char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = Char:FindFirstChildWhichIsA("Humanoid")
--\\ Gamepass Check \\--
if MPS:UserOwnsGamePassAsync(plr.UserId, 8179155411) then
wait(3)
if not Char then
local GamepassInfo = MPS:GetProductInfo(8179155411, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
else
if not Humanoid then
local GamepassInfo = MPS:GetProductInfo(8179155411, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
end
Humanoid.WalkSpeed *= 2
end
end
if MPS:UserOwnsGamePassAsync(plr.UserId, 8179153834) then
wait(3)
if not Char then
local GamepassInfo = MPS:GetProductInfo(8179153834, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
else
if not Humanoid then
local GamepassInfo = MPS:GetProductInfo(8179153834, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
end
Humanoid.JumpPower *= 2
end
end
--\\ Charactor Died Function \\--
Humanoid.Died:Connect(function()
wait(2) -- it will wait until the player respawned (the players respawn time is 0 but i wait 2 seconds to make sure the player spawned)
if MPS:UserOwnsGamePassAsync(plr.UserId, 8179155411) then
wait(3)
if not Char then
local GamepassInfo = MPS:GetProductInfo(8179155411, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
else
if not Humanoid then
local GamepassInfo = MPS:GetProductInfo(8179155411, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
end
Humanoid.WalkSpeed *= 2
end
end
if MPS:UserOwnsGamePassAsync(plr.UserId, 8179153834) then
wait(3)
if not Char then
local GamepassInfo = MPS:GetProductInfo(8179153834, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
else
if not Humanoid then
local GamepassInfo = MPS:GetProductInfo(8179153834, Enum.InfoType.GamePass)
game.ReplicatedStorage.CheckGamepassError:FireClient(plr, GamepassInfo.Name)
return
end
Humanoid.JumpPower *= 2
end
end
end)
end)
oh yea i also want to know like if the player died it also checks the gamepass to give them the speed and jump boost if its good