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 » Scripting Helpers
Home Search
 

Re: Badge VIP door script error

Previous Thread :: Next Thread 
monkey1589 is not online. monkey1589
Joined: 06 Feb 2010
Total Posts: 2334
03 Jan 2012 07:39 PM
Heres my script:
local user = "monkey1589" -- the player's username
local badgeId = 59719865 -- the shirt's assetId

local door = script.Parent

function onTouched(hit)
local player = game:GetService'Players':GetPlayerFromCharacter(hit.Parent) or game:GetService'Players':GetPlayerFromCharacter(hit.Parent)

if player and player.Character and (player.Name:lower() == user:lower() or game:GetService'BadgeService':UserHasBadge(badgeId)) then
local anchoredState = door.Anchored -- remember anchored
local transparencyState = door.Transparency -- remember transparency

door.Anchored = true
door.CanCollide = false
door.Transparency = 0.5

wait(4)

door.CanCollide = true
door.Anchored = anchoredState -- make it anchored like before
door.Transparency = transparencyState -- make it transparent like before
else
player.Character:BreakJoints()
end
end

door.Touched:connect(onTouched)

Heres my output:
18:36:47 - Argument 2 missing or nil
18:36:47 - Script "Workspace.door.Script", Line 9
18:36:47 - stack end

This is line 9:
if player and player.Character and (player.Name:lower() == user:lower() or game:GetService'BadgeService':UserHasBadge(badgeId)) then
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
03 Jan 2012 07:44 PM
You forgot parantheses.

game:GetService('BadgeService')
Report Abuse
theblob5743 is not online. theblob5743
Joined: 08 Nov 2008
Total Posts: 1574
03 Jan 2012 07:44 PM
Replace line 9 with this:
if player and player.Character and (player.Name:lower() == user:lower() or game:GetService'BadgeService':UserHasBadge(player.userId, badgeId)) then
Report Abuse
monkey1589 is not online. monkey1589
Joined: 06 Feb 2010
Total Posts: 2334
03 Jan 2012 07:45 PM
Thanks. Your both awesome. I'll try it out
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
03 Jan 2012 07:47 PM
@theblob

No. You also forgot parantheses. This is the fully edited line 9: (Replace line 9 with this)


if player and player.Character and (player.Name:lower() == user:lower() or game:GetService('BadgeService'):UserHasBadge(player.userId, badgeId)) then
Report Abuse
monkey1589 is not online. monkey1589
Joined: 06 Feb 2010
Total Posts: 2334
03 Jan 2012 07:49 PM
Output says this now:
18:48:15 - Workspace.door.Script:23: attempt to index local 'player' (a nil value)
18:48:15 - Script "Workspace.door.Script", Line 23
18:48:15 - stack end

Line 23 is this:
player.Character.Humanoid.Health = 0
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
03 Jan 2012 07:51 PM
Dude, you need to replace all your GetService'Service' with GetService('Service')


GetService requires parantheses.
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
03 Jan 2012 07:52 PM
And also, your sxcript is very inefficient. Why are you 'remembering' the anchored and transparency like before??? Setting them manually is much quicker.
Report Abuse
monkey1589 is not online. monkey1589
Joined: 06 Feb 2010
Total Posts: 2334
03 Jan 2012 07:58 PM
don't judge me
Report Abuse
theblob5743 is not online. theblob5743
Joined: 08 Nov 2008
Total Posts: 1574
03 Jan 2012 08:43 PM
Don't listen to him, the way you have it is perfectly fine. all you need to do is change the else in line 22 to:

elseif player and player.Character then

Also you should delete this:
or game:GetService'Players':GetPlayerFromCharacter(hit.Parent)
in line 7 because it is useless. Your new line 7 should look like this:
local player = game:GetService'Players':GetPlayerFromCharacter(hit.Parent)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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