Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Works on Local, but not on Server?

I've got a simple script that when it is clicked it will prompt a product purchase. Here is a sample code for a R$10 purchase.

productId = 33054891


script.Parent.ClickDetector.MouseClick:connect(function(plr)
	game:GetService("MarketplaceService"):PromptProductPurchase(plr, productId)
end)

script.Parent.ClickDetector.MouseHoverEnter:connect(function()
	script.Parent.SurfaceGui.Ammount.TextTransparency = 0.5
	script.Parent.SurfaceGui.Sign.TextTransparency = 0.5
	script.Parent.Enter.TextLabel.Visible = true
end)

script.Parent.ClickDetector.MouseHoverLeave:connect(function()
	script.Parent.SurfaceGui.Ammount.TextTransparency = 0
	script.Parent.SurfaceGui.Sign.TextTransparency = 0
	script.Parent.Enter.TextLabel.Visible = false
end)

Thank you in advance.

5 comments

0

I think you just have to call PromptProductPurchase from the player, rather than the server. http://wiki.roblox.com/index.php?title=Developer_product

0

Didn't work.

0

Is it within a GUI or a part..?

0

Part

0

Is this a LocalScript or a regular script?

1 answer

Your main problem here is either that plr is not defined, or your code is in a server script when it really should be local.

Move all your code into a LocalScript, and define the variable plr (probably as game.Players.LocalPlayer)

If you need the LocalScript to change a value on the server, use a RemoteEvent.

1 comment

1

plr is who ever hits the part, it is defined.

This discussion is preserved as it was. New answers, comments, and votes are closed.