Explorer: Model inside of workspace Part named head inside of model Humanoid in model Script inside of head:
local mps = game:GetService("MarketplaceService") local ID = "I don't wanna share this model, but yes, i put a valid ID WITHOUT the speech marks." function onHit(hit) if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then if not mps:PlayerOwnsAsset(player,ID) then mps:PromptPurchase(player,ID) end end
I want it to prompt the purchase for the model once the part has been touched, however it doesn't seem to be working. Any help? I wasn't sure whether to use onHit or onTouch, but I tried both and they didn't work.
Thanks!
You forgot script.Parent.Touched:Connect(onHit)
and end
There is the whole script:
local mps = game:GetService("MarketplaceService") local ID = "I don't wanna share this model, but yes, i put a valid ID WITHOUT the speech marks." function onHit(hit) if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then if not mps:PlayerOwnsAsset(player,ID) then mps:PromptPurchase(player,ID) end end end script.Parent.Touched:Connect(onHit)
'onHit' and 'onTouch are just function names commonly used to connect to the .Touched event. If you're somewhat unfamiliar with events, the wiki gives some insight on how they're used here.
Also, your explanation of the explorer confused me a bit, so I just assumed that the script is placed inside of the object that's being touched by some player:
local mps = game:GetService("MarketPlaceService") local ID = "I don't wanna share this model, but yes, i put a valid ID WITHOUT the speech marks." function onHit(hit) if hit.Parent:FindFirstChild("Humanoid") then -- The '~= nil' isn't really necessary local player = hit.Parent if not mps:PlayerOwnsAsset(player, ID) then mps:PromptPurchase(player, ID) end end end local partToTouch = script.Parent -- your model partToTouch.Touched:Connect(onHit) -- any time the part is touched, your function will fire.
I hope this helps!