RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 04 Jan 2014 02:05 PM |
| How do I make a script so that if you buy a game pass and then join the game that you will get a tool automatically which you don't lose upon death? |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2014 02:18 PM |
local GamePassId=0000; local ToolIndex=Game:GetService('ServerStorage'):FindFirstChild('LinkedSword'); Game['Players']['PlayerAdded']:connect(function(player) if Game:GetService('MarketplaceService'):PlayerHasPass(player,GamePassID) then ToolIndex:Clone()['Parent']=player['StarterGear']; end; end);
^Try that; I haven't tested it but it should work. |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2014 02:18 PM |
Oh, sorry!
local GamePassId=0000;
should be
local GamePassID=0000; |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 04 Jan 2014 02:20 PM |
| Just searched one in models but I just try yours :) thanks |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 04 Jan 2014 02:21 PM |
| btw whats diffrence between that two |
|
|
| Report Abuse |
|
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 05:18 AM |
| Both which I had did not work, any other scripts? ;s |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 05:49 AM |
| bump, the one who gives me a working script gets the game pass for free? :D |
|
|
| Report Abuse |
|
|
velibor
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 1003 |
|
|
| 05 Jan 2014 05:50 AM |
local GamePassId=0000; local ToolIndex=Game:GetService('ServerStorage'):FindFirstChild('LinkedSword'); Game['Players']['PlayerAdded']:connect(function(player) if Game:GetService('MarketplaceService'):PlayerOwnsAsset(player,GamePassID) then ToolIndex:Clone()['Parent']=player['StarterGear']; end; end);
Samuel had a wrong method. It is :PlayerOwnsAsset() not :PlayerHasPass(). Please use the Output window if you have such a bug ;)
|
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 06:21 AM |
| I will add it quickly then shower then eat then I will give you the free game pass ;p |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 06:24 AM |
Nope still does not work. Should I give you the script and the tool, maybe you can fix it then? :$ Or maybe it just does not work for me, but it does for others. |
|
|
| Report Abuse |
|
|
velibor
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 1003 |
|
|
| 05 Jan 2014 06:31 AM |
local GPI = 000 -- Your GamePass Id local Tool = 'The Name of your Tool' -- Put the Tool in ServerStorage
Game:GetService("Players").PlayerAdded:connect(function(Plr) if Game:GetService("MarketPlaceService"):PlayerOwnsAsset(Plr, GPI) then if Game:GetService("ServerStorage"):findFirstChild(Tool) then local Tool = Game:GetService("ServerStorage"):WaitForChild(Tool) Tool:Clone().Parent = Player.StarterGear end end end)
That should do the trick. Put this Script in Workspace, put the Tool inside ServerStorage Service.. |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
VoltiCoil
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 1227 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 05 Jan 2014 08:57 AM |
| .PlayerAdded events don't work in play solo, remember |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 09:07 AM |
| I know tried in the game itself, not play solo. |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
LejChris
|
  |
| Joined: 28 Dec 2013 |
| Total Posts: 13 |
|
|
| 05 Jan 2014 01:13 PM |
local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end
local GamePassService = Game:GetService('GamePassService') local PlayersService = Game:GetService('Players') local InsertService = Game:GetService('InsertService') local LightingService = Game:GetService('Lighting')
local GamePassIdObject = WaitForChild(script, 'GamePassId') local ToolAssetsToLoad = WaitForChild(script, 'ToolAssetsToLoad')
local AdminTools = LightingService:FindFirstChild('AdminTools')
local function CloneAdminTools(target) for _, tool in pairs(AdminTools:GetChildren()) do local toolClone = tool:Clone() toolClone.Parent = target end end
local function OnPlayerAdded(player) if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then local starterGear = WaitForChild(player, 'StarterGear') CloneAdminTools(starterGear) if player.Character then local backpack = WaitForChild(player, 'Backpack') CloneAdminTools(backpack) end end end
if not AdminTools then AdminTools = Instance.new('Model') AdminTools.Name = 'AdminTools'
for _, intObject in pairs(ToolAssetsToLoad:GetChildren()) do if intObject and intObject:IsA('IntValue') and intObject.Value then local assetModel = InsertService:LoadAsset(intObject.Value) if assetModel then local asset = assetModel:GetChildren()[1] if asset then asset.Parent = AdminTools end end end end
AdminTools.Parent = LightingService end
PlayersService.PlayerAdded:connect(OnPlayerAdded)
|
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 02:14 PM |
| where do I insert th game pass ID and the tool name? |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
|
| 05 Jan 2014 02:33 PM |
If it is here: local GamePassIdObject = WaitForChild(script, 'GamePassId') local ToolAssetsToLoad = WaitForChild(script, 'ToolAssetsToLoad') Then, it still does not work. Btw the tool is run and its icon is this orange handle with silver brick at it with a script next to it. |
|
|
| Report Abuse |
|
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|