Hi roblox devs today i got an Error in my script.that verify if user own the gamepass and connect to a function ,but its not woking i dont know why?i put it in serverscriptservice , can you help me to fix that script pls
local ms = game:GetService("MarketplaceService")
local passid = 718667987
local haspass = false
local rep = game:GetService("ReplicatedStorage")
local sword = rep:FindFirstChild("ClassicSword")
game.Players.PlayerAdded:Connect(function(player)
local success,error = pcall(function()
haspass= ms:UserOwnsGamePassAsync(player.UserId,passid)
if haspass then
print(player.Name.." own the pass")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local hum = character:FindFirstChild("Humanoid")
hum.WalkSpeed = 1000000
sword.Parent = player.Backpack
end)
end)
else
print(error.."ow the passss bro")
end
end)
end)
here is the script as you can explain its really a verify user own the gamepass.pls help me to fix the script Error.
and if help thanks! Enjoy!
Your answers are a bit confusing. I understand that English may not be your first language, but please answer these questions in order, in only one post:
Did your script work before today?
You said "it just do the print() " but you need to say which of the prints it’s doing (“owns the pass” or “ow the passss”).
Are there any errors printed in the Output window, and if yes then copy and paste the error here.
You said Studio lags.
Is it only Studio that lags?
Does your game on the website?
Do you have any other scripts that would cause the lag?
Have you added any free models from the Toolbox that had scripts inside them?
Have you installed any plugins that may have harmful scripts that could be causing issues with your game?
its print(“skinogodest own the pass”) but not the Humanoid and i have not use free model i never use it soo i just used moon animator 2 and studio not lag i think don’t have any error and enjoy i can share you a video
Is the issue because you are waiting for another player to join the game and then setting up a event where you will get the next person that joins character and then setting their speed to what ever number that is.
local ms = game:GetService("MarketplaceService")
local passid = 718667987
local haspass = false
local rep = game:GetService("ReplicatedStorage")
local sword = rep:FindFirstChild("ClassicSword")
game.Players.PlayerAdded:Connect(function(player)
local success,error = pcall(function()
haspass= ms:UserOwnsGamePassAsync(player.UserId,passid)
if haspass then
print(player.Name.." own the pass")
player.CharacterAdded:Connect(function(character)
local hum = character:FindFirstChild("Humanoid")
hum.WalkSpeed = 10000
sword.Parent = player.Backpack
end)
else
print(error.."ow the passss bro")
end
end)
end)
Okay, since you clearly do not understand what I am telling you I will just give you code that will work.
local ms = game:GetService("MarketplaceService")
local passid = 718667987
local haspass = false
local rep = game:GetService("ReplicatedStorage")
local sword = rep:FindFirstChild("ClassicSword")
game.Players.PlayerAdded:Connect(function(player)
local success,error = pcall(function()
haspass= ms:UserOwnsGamePassAsync(player.UserId,passid)
if haspass then
print(player.Name.." own the pass")
player.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 10000
sword.Parent = player.Backpack
else
print(error.."ow the passss bro")
end
end)
end)