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

Please help me solve why this script isn't working i got no answer last time?

Asked by 6 years ago
Edited 6 years ago

I created this script but it doesn't work, it's a VIP door. Don't know what I'm doing wrong but any and all help would be greatly appreciated, thanks. This is in a regular script inside a block.

local ID = 1369781260
plr = game.Players.LocalPlayer

debounce=false

function onTouched(hit)
    if debounce==true then return end
    debounce=true


    game:GetService("MarketplaceService"):PromptPurchase(plr, ID)


    debounce=false

end

script.Parent.Touched:connect(onTouched)


0
Is there a error in the logs? AlphaGamer150 101 — 6y
0
No QuantumScripter 48 — 6y
0
Then I can not help you AlphaGamer150 101 — 6y
0
Well thanks man. You sure tried. QuantumScripter 48 — 6y
View all comments (4 more)
0
I found out using print commands it doesn't get passed this command.... game:GetService("MarketplaceService"):PromptPurchase(plr, ID) QuantumScripter 48 — 6y
0
15:03:25.054 - MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil. -----Tat's the error. QuantumScripter 48 — 6y
0
You cannot use LocalPlayer in a regular script. UgOsMiLy 1074 — 6y
0
I put it all in a local script and now it doesn't work at all QuantumScripter 48 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago
local ID = 1369781260
debounce=false

function onTouched(hit)
    if debounce==true then return end
        debounce=true
        local plr = game.Players:WaitForChild(hit.Parent
Name)

        game:GetService("MarketplaceService"):PromptPurchase(plr, ID)

        debounce=false
    end
end

script.Parent.Touched:connect(onTouched)

0
Try that. ^ MachoPiggies 526 — 6y
0
No errors but i don't know if it's working because i added print commands in the beginning, middle, and end and didn't read any of them... QuantumScripter 48 — 6y
0
Can you tell me where the script is located and put a print at every stage of the script including before the touched event? MachoPiggies 526 — 6y
0
The script is located inside a part. It is a local script. QuantumScripter 48 — 6y
View all comments (6 more)
0
Make it a serverscript please. MachoPiggies 526 — 6y
0
It doesn't get past this.... local plr = game.Players:WaitForChild(hit.ParentName) QuantumScripter 48 — 6y
0
Please keep helping. QuantumScripter 48 — 6y
0
Use GetPlayerFromCharacter. hiimgoodpack 2009 — 6y
0
Or just add a dot between Parent.Name MachoPiggies 526 — 6y
0
Thank you so much i added the dot and fixed it. It works perfectly now QuantumScripter 48 — 6y
Ad
Log in to vote
1
Answered by
ax_gold 360 Moderation Voter
6 years ago
Edited 6 years ago

Roblox's GamePass service likes to act stupid. try this script.

local ID = 1369781260
debounce=false
local market = game:GetService("MarketplaceService")
local pass = game:GetService("GamePassService")

function onTouched(hit)
    if debounce ~= true then
    debounce = true
    if hit.Name ~= "Handle" then
        local plr = game.Players:WaitForChild(hit.Parent.Name)
        if not pass:PlayerHasPass(plr, ID) then
            market:PromptPurchase(plr , ID)
        end
    else
        local plr = game.Players:WaitForChild(hit.Parent.Parent.Name)
        if not pass:PlayerHasPass(plr, ID) then
            market:PromptPurchase(plr , ID)
        end
    end
        debounce=false
    end
end

script.Parent.Touched:connect(onTouched)

if it doesn't work, let me know. Also, sometimes the part hits the player's hair before it hits the actual body, so I added in a workaround for that as well.

0
That is the most ridiculously overly complicated script I have ever seen. MachoPiggies 526 — 6y
0
It's not that complicated if you actually read it. Also, I've made many scripts that are more complicated. ax_gold 360 — 6y
0
No errors but the script doesn't work. It doesn't pull up the product that i have for sale. QuantumScripter 48 — 6y
0
I put it in a server side script not a local. QuantumScripter 48 — 6y
0
That's weird. It works on my computer. I even put it into a published game to test it on roblox and it still worked. ax_gold 360 — 6y

Answer this question