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: Script problem

Previous Thread :: Next Thread 
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
24 Nov 2011 11:22 PM
humanoid = game.Workspace.Humanoid.ClassName
redgun = game.Lighting.RedGun

game.Players.PlayerAdded:connect(function(p)
if p.TeamColor == BrickColor.new("Bright red") then
while wait() do
if not p:findFirstChild("Backpack") then
wait()
else
break
end
end
redgun:clone().Parent = p.StarterGear
redgun:clone().Parent = p.Backpack
end

c = p.Character
a = game.Workspace:findFirstChild(c)

function IsAChild(humanoid,a)
if humanoid.Parent == a then
sg = a:findFirstChild("Shirt graphic")
if sg then --if sg exists
sg:remove()
end
s = a:findFirstChild("Shirt")
if s then --if s exists
s:remove()
end
p = a:findFirstChild("Pants")
if p then --if p exists
p:remove()
end
sg = a:findFirstChild("Hat")
if h then --if h exists
h:remove()
end
end
end

end)

The first function executes fine, but the second one doesn't work. The output doesn't give any errors.
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 10:45 AM
*bump*
Report Abuse
sncplay42 is not online. sncplay42
Joined: 27 Nov 2008
Total Posts: 11891
25 Nov 2011 10:54 AM
You need to call it or connect it to an event to run.

function IsAChild(a)
sg = a:findFirstChild("Shirt graphic")
if sg then --if sg exists
sg:remove()
end
s = a:findFirstChild("Shirt")
if s then --if s exists
s:remove()
end
p = a:findFirstChild("Pants")
if p then --if p exists
p:remove()
end
sg = a:findFirstChild("Hat")
if h then --if h exists
h:remove()
end
end

p.CharacterAdded:connect(function(character)
for i, obj in ipairs(character:GetChildren()) do
IsAChild(obj)
end
end)
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 10:57 AM
Put it's already connected to game.Players.PlayerAdded:connect(function(p)
Report Abuse
sncplay42 is not online. sncplay42
Joined: 27 Nov 2008
Total Posts: 11891
25 Nov 2011 10:59 AM
IsAChild isn't.
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 11:00 AM
Oh, ok :P
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 11:06 AM
That errored with an eof expected so I added an end before the end) and now it wants and end) to close the ( in line 41 - p.CharacterAdded:connect(function(character)
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 11:23 AM
*bump*
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 12:16 PM
*bump*
Report Abuse
sncplay42 is not online. sncplay42
Joined: 27 Nov 2008
Total Posts: 11891
25 Nov 2011 01:12 PM
Did you insert that function back into the script right? Here's the full script:

humanoid = game.Workspace.Humanoid.ClassName
redgun = game.Lighting.RedGun

game.Players.PlayerAdded:connect(function(p)
if p.TeamColor == BrickColor.new("Bright red") then
while wait() do
if not p:findFirstChild("Backpack") then
wait()
else
break
end
end
redgun:clone().Parent = p.StarterGear
redgun:clone().Parent = p.Backpack
end

--the variables here weren't used

function IsAChild(a)
sg = a:findFirstChild("Shirt graphic")
if sg then --if sg exists
sg:remove()
end
s = a:findFirstChild("Shirt")
if s then --if s exists
s:remove()
end
p = a:findFirstChild("Pants")
if p then --if p exists
p:remove()
end
sg = a:findFirstChild("Hat")
if h then --if h exists
h:remove()
end
end

p.CharacterAdded:connect(function(character)
for i, obj in ipairs(character:GetChildren()) do
IsAChild(obj)
end
end)

end)
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 02:21 PM
That said unexpected character near ')' in the last line so I removed the ), then it said an end was expected at line 48 to close a function so I added the end. It then said it expected a ')' near the end I added so I put it in and we're back to my first problem - the first function runs fine but the second doesn't work.
Report Abuse
sncplay42 is not online. sncplay42
Joined: 27 Nov 2008
Total Posts: 11891
25 Nov 2011 02:22 PM
The full script as I posted it worked fine for me =/
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 05:30 PM
I tried it again and it's not erroring, but it's still not taking my clothes off.
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
25 Nov 2011 08:24 PM
*bump*
Report Abuse
maurissquad is not online. maurissquad
Joined: 17 Nov 2011
Total Posts: 191
26 Nov 2011 01:06 PM
*bump*
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