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: character help

Previous Thread :: Next Thread 
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
25 Mar 2015 11:41 PM
this is a really simple problem, and excuse me if the error is blatantly obvious, i'm tired as of now

so, i've been looping through the character to find if they have a shirt/pants object

i tested in studio with my character,and even though i am clearly wearing a shirt and pants, the script doesn't work properly. it doesn't set the shirtFound variable to true, same goes for the pantsFound variable

here is some of the script

--character is defined btw

for i, v in next, character:GetChildren() do
print(v)
if v:IsA("Shirt") then
print(v)
shirt = v
print("shirt's path: "..shirt:GetFullName())
shirtFound = true
end

if v:IsA("Pants") then
print(v)
pants = v
print("pants's path: "..pants:GetFullName())
pantsFound = true
end
end

print("shirtFound = "..tostring(shirtFound))
print("foundPants = "..tostring(pantsFound))

output:
>Head
>Torso
>Left Arm
>Right Arm
>Left Leg
>Right Leg
>Humanoid
>HumanoidRootPart
>Sound
>Animate
>ForceField
>shirtFound = false
>foundPants = false

but i'm wearing a shirt and pants, and the shirt or pants doesn't get printed..
and muh variables too..
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 09:05 AM
skroptrs pls
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 12:33 PM
bump1337
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 01:03 PM
do i need to explain this better? if i do, it isn't a problem
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
26 Mar 2015 01:18 PM
This loops it every 5 seconds. you don't have to use a loop though

local players = game.Players.LocalPlayer
local c = players.Character
while wait(5) do
for i, v in pairs(c:GetChildren()) do
print(v)
if v:IsA("Shirt") then
print(v)
local shirt = v
print("shirt's path: "..shirt:GetFullName())
shirtFound = true
end

if v:IsA("Pants") then
print(v)
local pants = v
print("pants's path: "..pants:GetFullName())
pantsFound = true
end

end
print("shirtFound = "..tostring(shirtFound))
print("foundPants = "..tostring(pantsFound))
end
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 01:31 PM
your script didn't work qq

shirtFound and pantsFound still returned false

i checked the character i was testing with in the explorer, and a shirt and pants object were inside the character

if it helps, i'm running these tests in play mode/play solo in studio

i tested in a real server, and checked the dev console, same result
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 01:48 PM
i'll just post all the original code because i was going to make this a free model for groups to use

i'll explain the layout of everything in the explorer

so, the main script is in server script service. there is then a folder inside of the script named Settings. inside of the Settings folder are 3 int values, and a README script for instructions. the intvalue's values are supposed to be ID numbers that lead to shirts/pants, and the 3rd value is the group's group ID number. you would insert the IDs into the appropiate intvalues.

here is what it looks like in the explorer

-ServerScriptService
--UniformProvider
---Settings
----GroupID int value
----UniformShirt ID int value
----README script
----UniformPants ID int value

here is the script, it is the giveOutfit function that doesn't work properly. it does not find a shirt or pants object if there is one inside of the character

Settings = script:WaitForChild("Settings")
shirtID = Settings:WaitForChild("UniformShirt").Value
pantsID = Settings:WaitForChild("UniformPants").Value
groupID = Settings:WaitForChild("GroupID").Value

shirtFound = false
pantsFound = false

function giveOutfit(characterToGiveTo, ID, ID2) --first parameter is the character to give to, the 2nd parameter is the shirt id, the 3rd parameter is the pants id
for i, charChild in next, characterToGiveTo:GetChildren() do
print(charChild)

if charChild:IsA("Shirt") then
shirt = charChild
shirtFound = true
print("child is a shirt, child's path: "..shirt:GetFullName())
end

if charChild:IsA("Pants") then
pants = charChild
pantsFound = true
print("child is a pants, child's path: "..pants:GetFullName())
end

if shirtFound then
print("shirt found")
print("shirtFound = "..tostring(shirtFound))
end

if pantsFound then
print("pants found")
print("pantsFound = "..tostring(pantsFound))
end

end
end

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
if plr:IsInGroup(groupID) then
print(plr.Name.." is in groupID "..groupID)
repeat wait() until char
print("char loaded")
giveOutfit(char, shirtID, pantsID)--script stops working here, does not find a shirt/pants object even if there is one
end
end)
end)
Report Abuse
kert109 is not online. kert109
Joined: 31 Dec 2009
Total Posts: 681
26 Mar 2015 01:51 PM
Add a Player:WaitForDataReady() or add a wait. Possible that you're not giving it enough time for the shirt/pants to load.

Try in online mode if you use Player:WaitForDataReady()
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
26 Mar 2015 01:53 PM
i'll try adding a wait, and see if that gives the character more time to load properly i suppose.
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
26 Mar 2015 04:14 PM
"print(v)"
If I'm correct, this line means you are printing the object, not it's name, the reason why shirtFound and foundPants are false is because it probably stuck at that line.





lel this is a stupid answer bye.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
26 Mar 2015 04:20 PM
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local found = false
for i,c in pairs(character)do
if c:IsA("Shirt") then
found = true
end
if found == true then
print(character.Name.. " is wearing a shirt. Shirt has been found.")
return true
else
return false
end
end
end)
end)



#໓นrŞt (RAP:586,192 - R$153,997 - Tx7,202) [British. Tea slurper. -slurps tea-]
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
26 Mar 2015 04:20 PM
oops, needed to add a wait..

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
wait(1)
local found = false
for i,c in pairs(character)do
if c:IsA("Shirt") then
found = true
end
if found == true then
print(character.Name.. " is wearing a shirt. Shirt has been found.")
return true
else
return false
end
end
end)
end)

try this.


#໓นrŞt (RAP:586,192 - R$153,997 - Tx7,202) [British. Tea slurper. -slurps tea-]
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
26 Mar 2015 04:23 PM
Whoops, once again messed it up..

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
wait(1)
local found = false
for i,c in pairs(character:GetChildren())do
if c:IsA("Shirt") then
found = true
end
if found == true then
print(character.Name.. " is wearing a shirt. Shirt has been found.")
return true
else
return false
end
end
end)
end)



#໓นrŞt (RAP:586,192 - R$153,997 - Tx7,244) [British. Tea slurper. -slurps tea-]
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