I try to create a gamepass that i can use in my game, but it doesnt work.
Here is the code
local gamepass = 10954412 game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if game:GetService("MarketplaceService"):PlayerOwnsAsset(player.userId, gamepass) then local h = character:WaitForChild("Humanoid") h.WalkSpeed = 50 end end) end)
the output says
Unable to cast value to Object
Script 'Workspace.GamePass', Line 5
Your issue in your script is that in line 5 it should be UserId instead or userId.
This will work, my spelling maybe wrong.
local Id = ######### -- Enter Id Here. game.Player.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if game:GetService("MarkertPlaceService"):UserOwnsAsyncGamePass(Player.UserId, Id) then Character:FindFirstChild("Humanoid").WalkSpeed = 50 end end) end)
If you want to give yourself specifically speed then you can just do the following...
game.Player.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if Player.Name == "YOUR NAME HERE" then Character:FindFirstChild("Humanoid").WalkSpeed = 50 end end) end)