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 7 years ago
Edited 7 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.

01local ID = 1369781260
02plr = game.Players.LocalPlayer
03 
04debounce=false
05 
06function onTouched(hit)
07    if debounce==true then return end
08    debounce=true
09 
10 
11    game:GetService("MarketplaceService"):PromptPurchase(plr, ID)
12 
13 
14    debounce=false
15 
16end
17 
18script.Parent.Touched:connect(onTouched)
0
Is there a error in the logs? AlphaGamer150 101 — 7y
0
No QuantumScripter 48 — 7y
0
Then I can not help you AlphaGamer150 101 — 7y
0
Well thanks man. You sure tried. QuantumScripter 48 — 7y
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 — 7y
0
15:03:25.054 - MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil. -----Tat's the error. QuantumScripter 48 — 7y
0
You cannot use LocalPlayer in a regular script. UgOsMiLy 1074 — 7y
0
I put it all in a local script and now it doesn't work at all QuantumScripter 48 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
01local ID = 1369781260
02debounce=false
03 
04function onTouched(hit)
05    if debounce==true then return end
06        debounce=true
07        local plr = game.Players:WaitForChild(hit.Parent
08Name)
09 
10        game:GetService("MarketplaceService"):PromptPurchase(plr, ID)
11 
12        debounce=false
13    end
14end
15 
16script.Parent.Touched:connect(onTouched)
0
Try that. ^ MachoPiggies 526 — 7y
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 — 7y
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 — 7y
0
The script is located inside a part. It is a local script. QuantumScripter 48 — 7y
View all comments (6 more)
0
Make it a serverscript please. MachoPiggies 526 — 7y
0
It doesn't get past this.... local plr = game.Players:WaitForChild(hit.ParentName) QuantumScripter 48 — 7y
0
Please keep helping. QuantumScripter 48 — 7y
0
Use GetPlayerFromCharacter. hiimgoodpack 2009 — 7y
0
Or just add a dot between Parent.Name MachoPiggies 526 — 7y
0
Thank you so much i added the dot and fixed it. It works perfectly now QuantumScripter 48 — 7y
Ad
Log in to vote
1
Answered by
ax_gold 360 Moderation Voter
7 years ago
Edited 7 years ago

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

01local ID = 1369781260
02debounce=false
03local market = game:GetService("MarketplaceService")
04local pass = game:GetService("GamePassService")
05 
06function onTouched(hit)
07    if debounce ~= true then
08    debounce = true
09    if hit.Name ~= "Handle" then
10        local plr = game.Players:WaitForChild(hit.Parent.Name)
11        if not pass:PlayerHasPass(plr, ID) then
12            market:PromptPurchase(plr , ID)
13        end
14    else
15        local plr = game.Players:WaitForChild(hit.Parent.Parent.Name)
View all 24 lines...

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 — 7y
0
It's not that complicated if you actually read it. Also, I've made many scripts that are more complicated. ax_gold 360 — 7y
0
No errors but the script doesn't work. It doesn't pull up the product that i have for sale. QuantumScripter 48 — 7y
0
I put it in a server side script not a local. QuantumScripter 48 — 7y
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 — 7y

Answer this question