I have a relatively simple script that, will, when you buy a developer product, grant you the abilities.
My script doesn’t work for some reason, in studio it will work, but it doesn’t ever work in an actual game. The lines that error in this script are marked with an error comment to the side
MarketplaceService.ProcessReceipt = function(recietInfo)
if recietInfo.ProductId == 1278432013 then -- walk
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Walk.Value = true
Player.Character:WaitForChild("Humanoid").WalkSpeed=16-- errors
elseif recietInfo.ProductId == 1278432012 then -- jump
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Jump.Value = true
Player.Character:WaitForChild("Humanoid").UseJumpPower=true -- errors
Player.Character.Humanoid.JumpPower = 50
elseif recietInfo.ProductId == 1278432011 then -- chat
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Chat.Value = true
Player.ChatsLeft.Value = 5
end
end
Works in studio usually, but doesn’t always work in a server. This script is located in SSS as a Script.
Maybe add an extra if statement checking to make sure that the player exists, as well, checking if the character isn’t nil before changing the Humanoid Properties. See if that could help.
Something like this, fix my indentation I’m on mobile lol.
MarketplaceService.ProcessReceipt = function(recietInfo)
if recietInfo.ProductId == 1278432013 then -- walk
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Walk.Value = true
if Player.Character ~= nil then
character = Player.Character
character:WaitForChild("Humanoid").WalkSpeed=16-- errors
elseif recietInfo.ProductId == 1278432012 then -- jump
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Jump.Value = true
if Player.Character ~= nil then
character = Player.Character
character:WaitForChild("Humanoid").UseJumpPower=true -- errors
Player.Character.Humanoid.JumpPower = 50
elseif recietInfo.ProductId == 1278432011 then -- chat
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Chat.Value = true
Player.ChatsLeft.Value = 5
end
end
game.Players.PlayerAdded:Connect(function(Player)
MarketplaceService.ProcessReceipt = function(recietInfo)
if recietInfo.ProductId == 1278432013 then -- walk
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Walk.Value = true
Player.Character:WaitForChild("Humanoid").WalkSpeed=16-- errors
elseif recietInfo.ProductId == 1278432012 then -- jump
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Jump.Value = true
Player.Character:WaitForChild("Humanoid").UseJumpPower=true -- errors
Player.Character.Humanoid.JumpPower = 50
elseif recietInfo.ProductId == 1278432011 then -- chat
local Player = Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Chat.Value = true
Player.ChatsLeft.Value = 5
end
end
end)
I’ve had this issue myself too alot of the times and I think I know how to fix it, here try this:
oh and I should also address it that its good to add a if statement for character, you can add it if you want
MarketplaceService.ProcessReceipt = function(recietInfo)
if recietInfo.ProductId == 1278432013 then -- walk
local Player = game.Players:GetPlayerByUserId(recietInfo.PlayerId)
local Character = game.Workspace:WaitForChild(Player.Name)
Player.Walk.Value = true
Character:WaitForChild("Humanoid").WalkSpeed=16-- errors
elseif recietInfo.ProductId == 1278432012 then -- jump
local Player = game.Players:GetPlayerByUserId(recietInfo.PlayerId)
local Character = game.Workspace:WaitForChild(Player.Name)
Player.Jump.Value = true
Character :WaitForChild("Humanoid").UseJumpPower=true -- errors
Character .Humanoid.JumpPower = 50
elseif recietInfo.ProductId == 1278432011 then -- chat
local Player = game.Players:GetPlayerByUserId(recietInfo.PlayerId)
Player.Chat.Value = true
Player.ChatsLeft.Value = 5
end
end
MarketplaceService.ProcessReceipt = function(recietInfo)
local Player = game.Players:GetPlayerByUserId(recietInfo.PlayerId)
local Character = game.Workspace:WaitForChild(Player)
if recietInfo.ProductId == 1278432013 then -- walk
Player.Walk.Value = true
Character:WaitForChild("Humanoid").WalkSpeed=16-- errors
elseif recietInfo.ProductId == 1278432012 then -- jump
Player.Jump.Value = true
Character :WaitForChild("Humanoid").UseJumpPower=true -- errors
Character .Humanoid.JumpPower = 50
elseif recietInfo.ProductId == 1278432011 then -- chat
Player.Chat.Value = true
Player.ChatsLeft.Value = 5
end
end
Not sure if this will work … but, your error is within these two lines. It’s not returning the Character.
Focus in on that part of the script. To make sure it’s returning the correct value I added a print(Character) check.
local Player = game.Players:GetPlayerByUserId(recietInfo.PlayerId)
local Character = game.Workspace:WaitForChild(Player.Name)
Also there is no need to put that in every if…
Some other guesses …
local Character = game.Workspace:WaitForChild(tostring(Player.Name))
local Character = Player.Character
That last version is normally how you would do that.
@Lorourkethebest it’s been a few days since you have not replied to any of the posts above. Have you solved this issue yet? If you have, could you please let us know