Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Works on Local, but not on Server?

Asked by 8 years ago

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.

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 GoldenPhysics 474 — 8y
0
Didn't work. JamesLWalker 297 — 8y
0
Is it within a GUI or a part..? IcyEvil 260 — 8y
0
Part JamesLWalker 297 — 8y
0
Is this a LocalScript or a regular script? P100D 590 — 8y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
8 years ago

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
plr is who ever hits the part, it is defined. JamesLWalker 297 — 8y
Ad

Answer this question