I tested the code ingame and it seems like to me it isn't reading when R is pressed.
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R and highlightstick == false then
if not game:GetService("MarketplaceService"):UserOwnsGamePassAsync(a.UserId,5815263) and a.Name~="Player1" then
game:GetService("MarketplaceService"):PromptGamePassPurchase(a,5815263)
else
highlightstick = true
script.Parent.Size = script.Parent.Size.Vector3.new(0,0,0)
print("worked")
wait(2)
highlightstick = false
script.Parent.Size = script.Parent.Size.Vector3.new(2,4,2)
print("worked1")
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

4 comments
This script is very complicated to read. It can be more simplified.
That doesn't help the problem at hand
It doesn't automatically provide both the arguments, that has to be defined manually I believe
also :connect is deprecated, use :Connect