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: CharacterAdded function not working..

Previous Thread :: Next Thread 
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
16 Feb 2014 11:22 AM
The last function that launches "uni()" (at the bottom) is not working, what am I doing wrong. :/

-----------------------------------------------------

player = game.Players.LocalPlayer
character = player.Character
red = game.Lighting.red
blue = game.Lighting.blue

function uni()
if character:findFirstChild("Shirt") ~= nil then
character.Shirt:Remove()
end
if character:findFirstChild("Pants") ~= nil then
character.Pants:Remove()
end
if player.TeamColor == BrickColor.new("Bright red") then
rs = red.Shirt:Clone()
rp = red.Pants:Clone()
rs.Parent = character
rp.Parent = character
elseif player.TeamColor == BrickColor.new("Bright blue") then
bs = blue.Shirt:Clone()
bp = blue.Pants:Clone()
bs.Parent = character
bp.Parent = character
end

end

player.CharacterAdded:connect(function(character)
uni()
end)
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
16 Feb 2014 11:24 AM
I'm assuming this script is in StarterPack or StarterGui. If I'm right in assuming that, you don't need to use an event - at all.



Report Abuse
SFOH is not online. SFOH
Joined: 01 Nov 2009
Total Posts: 293
16 Feb 2014 11:24 AM
you forgot to connect character into uni()

therefore, it should be uni(character)
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
16 Feb 2014 11:28 AM
@DataStore I started off by doing that but the script doesn't seem to reset on character's death so it just runs once..
Report Abuse
Vuva is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
16 Feb 2014 11:30 AM
uni(character) wouldn't work because the function was never defined with any parameters.
And plus it's kinda unnecesary since character was already defined at the top...
Try this:

player = game.Players.LocalPlayer
character = player.Character
red = game.Lighting.red
blue = game.Lighting.blue
function uni()
if character:findFirstChild("Shirt") ~= nil then
character.Shirt:Remove()
end
if character:findFirstChild("Pants") ~= nil then
character.Pants:Remove()
end
if player.TeamColor == BrickColor.new("Bright red") then
rs = red.Shirt:Clone()
rp = red.Pants:Clone()
rs.Parent = character
rp.Parent = character
elseif player.TeamColor == BrickColor.new("Bright blue") then
bs = blue.Shirt:Clone()
bp = blue.Pants:Clone()
bs.Parent = character
bp.Parent = character
end
end
player.CharacterAdded:connect(uni)
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
16 Feb 2014 11:34 AM
That seemed like a good idea but its not working neither :/ does it have something to do that this is inside StarterGui and it is a local script?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 11:38 AM
red = game.Lighting.red
blue = game.Lighting.blue

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)--this will run every time the character respawns
for I,v in pairs(char:GetChildren()) do
if v:IsA ("Shirt") or v:IsA ("Pants") then
v:destroy()
end
end
if plr.TeamColor == BrickColor.new("Bright red") then
rs = red.Shirt:clone()
rp = red.Pants:clone()
rs.Parent = char
rp.Parent = char
elseif plr.TeamColor == BrickColor.new("Bright blue") then
bs = blue.Shirt:clone()
bp = blue.Pants:clone()
bs.Parent = char
bp.Parent = char
end
end)
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 11:39 AM
ps
character = player.Character?
you were attempting to define character BEFORE it spawned,anyway,hope I helped:D

-islandmaker2012,here to..eat pizza?..no!save da day!-
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 11:39 AM
with my script,put It in workspace,and test in server
Report Abuse
SFOH is not online. SFOH
Joined: 01 Nov 2009
Total Posts: 293
16 Feb 2014 11:41 AM
game.Players.PlayerAdded:connect(function(f) f.CharacterAdded:connect(function(g) uni(g) end)end)
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
16 Feb 2014 11:50 AM
@islandmaker2012 I tried adding it into workspace but its still not working for some reason its no even going into the PlayerAdded function (I tried to test using print'') :(
Report Abuse
SFOH is not online. SFOH
Joined: 01 Nov 2009
Total Posts: 293
16 Feb 2014 11:56 AM
HOW ABOUT YOU TRY AND USE MY SCRIPTING ADVICE?
HOW ABOUT THAT?
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
16 Feb 2014 12:02 PM
Its not working :/
But i've recently discovered it DOES go through all the script but for some reason it skips adding the shirt and pants to the player, no idea why. e.e
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