generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: HELP QUICK [URGENT]

Previous Thread :: Next Thread 
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
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
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:32 AM
bb


cow goes moo
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:33 AM
bump


cow goes moo
Report Abuse
Soybeen is not online. 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 is not online. 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
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
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 is not online. iYoshiFox
Joined: 14 Apr 2012
Total Posts: 1058
30 Dec 2016 06:42 AM
Make it a local script
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:43 AM
in workspace?


cow goes moo
Report Abuse
iYoshiFox is not online. 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 is not online. 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
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
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
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:50 AM
bumpy


cow goes moo
Report Abuse
Soybeen is not online. 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 is not online. 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 is not online. Korniak
Joined: 09 Aug 2013
Total Posts: 3538
30 Dec 2016 06:53 AM
low-key flames from the soy bean
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:54 AM
hmm. that's complex....




cow goes moo
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:56 AM
hmmmmm


cow goes moo
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 06:58 AM
aww just hit my 1k without knowing


cow goes moo
Report Abuse
Royalvurse is not online. Royalvurse
Joined: 13 May 2016
Total Posts: 1003
30 Dec 2016 08:14 AM
Yay I did it!
using remote events!!! THANKS GUYS!!


cow goes moo
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
30 Dec 2016 08:17 AM
Nice one


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image