|
| 30 Dec 2016 06:31 AM |
So I made a pet script, but I want it to only give you the pet if you own a gamepass. It's in a script in workspace. It's not working.
Here's the script:
local GamePassService = game:GetService('GamePassService')
local function OnPlayerAdded(player) if game.GamePassService:PlayerHasPass(player,594184051) then local p = game.Players.LocalPlayer local char = p.Character or p.CharacterAdded:wait()
local orb = Instance.new('Part', char) orb.Name = 'Orb' orb.CanCollide = false
local mesh = Instance.new("SpecialMesh",orb) mesh.MeshType = "FileMesh" mesh.TextureId = "rbxassetid://329865098" mesh.MeshId = "rbxassetid://329864728" mesh.Scale = Vector3.new(1,1,1)
local body = Instance.new('BodyPosition', orb) local gyro = Instance.new('BodyGyro', orb) gyro.maxTorque = Vector3.new(1,1,1)/0
while wait() do body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0)) gyro.cframe = CFrame.new(Vector3.new(), char.Head.CFrame.lookVector) end
while wait() do body.Position = char.Head.Position + Vector3.new(2,1,0) end
body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0))
end end
cow goes moo |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:34 AM |
You need to use the :PlayerOwnsAsset method of the MarketplaceService instead. PlayerHasPass doesn't work if they buy the item while playing the game.
It would like like...
local ms = game:GetService("MarkeplaceService") local assetId = 594184051 game.Players.PlayerAdded:connect(function(player) if ms:PlayerOwnsAsset(player,assetId) then print("player owns the asset") end end)
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:35 AM |
Also don't bump once a minute. Like damn.
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:41 AM |
apparently there is something wrong with this bit:
local p = game.Players.LocalPlayer local char = p.Character or p.CharacterAdded:wait()
is it something to do with it being in a normal script? im fairly new to scripting
cow goes moo |
|
|
| Report Abuse |
|
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
| |
|
| |
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 30 Dec 2016 06:43 AM |
No it's client specific, so put it in somewhere like StarterGui or StarterPack.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:43 AM |
Think about it this way: "normal" scripts are "server scripts" "LocalPlayer" implies the player specific to the client client ~= server
Therefore, you should use a /local/ script when getting game.Players.LocalPlayer.
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:48 AM |
Ok... The code is in a LocalScript in Starter GUI. It still doesn't give me a pet when I join the game even though I own the gamepass.
Here's the final code: local ms = game:GetService("MarketplaceService") local assetId = 594184051 game.Players.PlayerAdded:connect(function(player) if ms:PlayerOwnsAsset(player,assetId) then local p = game.Players.LocalPlayer local char = p.Character or p.CharacterAdded:wait()
local orb = Instance.new('Part', char) orb.Name = 'Orb' orb.CanCollide = false
local mesh = Instance.new("SpecialMesh",orb) mesh.MeshType = "FileMesh" mesh.TextureId = "rbxassetid://329865098" mesh.MeshId = "rbxassetid://329864728" mesh.Scale = Vector3.new(1,1,1)
local body = Instance.new('BodyPosition', orb) local gyro = Instance.new('BodyGyro', orb) gyro.maxTorque = Vector3.new(1,1,1)/0
while wait() do body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0)) gyro.cframe = CFrame.new(Vector3.new(), char.Head.CFrame.lookVector) end
while wait() do body.Position = char.Head.Position + Vector3.new(2,1,0) end
body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0)) end end)
cow goes moo |
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:51 AM |
Because you're trying to move something with a local script.
Affect things on the server with a server script Affect things on the client with a local script
When you need to cross-reference, use RemoteEvents and RemoteFunctions If you don't understand them, learn them here: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial
However, you shouldn't need them to make a pet follow a joining player who owns a gamepass. You can do all that on the server.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:51 AM |
What'd I say about bumping
This isn't the soup of degenerates that is LMaD.
|
|
|
| Report Abuse |
|
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
|
| 30 Dec 2016 06:53 AM |
| low-key flames from the soy bean |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:54 AM |
hmm. that's complex....
cow goes moo |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Dec 2016 06:58 AM |
aww just hit my 1k without knowing
cow goes moo |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 08:14 AM |
Yay I did it! using remote events!!! THANKS GUYS!!
cow goes moo |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|