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: Changing Materials

Previous Thread :: Next Thread 
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 09:46 PM
Changing materials by time of day, at 6AM it's neon and at 8PM it's Smooth Plastic

Please debug:

modelL = script.Parent.WindowLightning
allChildren = modelL.GetChildren()

while true do
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
modelL.allChildren.Material.new = "Neon"
end
end
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
modelL.allChildren.Material.new = "Smooth Plastic"
end
end
end
Report Abuse
HalfPinky456 is online. HalfPinky456
Joined: 10 Apr 2011
Total Posts: 6236
15 Aug 2016 10:11 PM
modelL = script.Parent.WindowLightning
allChildren = modelL:GetChildren()

while true do
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
allChildren.Material.new = "Neon"
end
end
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
allChildren.Material.new = "Smooth Plastic"
end
end
end


nothin' like a good argument ¯\_(ツ)_/¯
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:20 PM
I fixed the :
but it still won't work
Report Abuse
devHoodie is not online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
15 Aug 2016 10:20 PM
Remember, when you call :GetChildren() it returns a TABLE of all the children.

so to go through each part and change the material do this:
for i,v in pairs (model:GetChildren()) do
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
v.Material = Enum.Material.Neon
elseif game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
15 Aug 2016 10:21 PM
for i,v in next, model:GetChildren() do
v.Material = Enum.Material.Neon
end


Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:26 PM
I looked for "in pairs" or "child in pairs" on the Wiki, no results that I found useful. What is it?
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:28 PM
And still not working?
model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
v.Material = Enum.Material.Neon
elseif game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:37 PM
Updated:

model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
if v:IsA("BasePart") then
v.Material = Enum.Material.Neon
elseif game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
end
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:39 PM
game.Lightning kek

Formerly ToxicDominator - add 17,509 posts
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:40 PM
kek?

What?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:42 PM
"game.Lightning"

game.Lighting*

Formerly ToxicDominator - add 17,509 posts
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:44 PM
Fixed that... Still not working?
model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lighting.GetHoursAfterMidnight() == 6 * 60 then
if v:IsA("BasePart") then
v.Material = Enum.Material.Neon
elseif game.Lighting.GetHoursAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
end
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:44 PM
1) "GetHoursAfterMidnight" that doesn't exist
2) even if you were attempting to get hours after midnight, why would you be multiplying by 60 anyway

Formerly ToxicDominator - add 17,509 posts
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:45 PM
and it's also a function, are you even using the wiki/output?

Formerly ToxicDominator - add 17,509 posts
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:50 PM
Using both to make:
modelL = script.Parent.WindowLightning
allChildren = modelL.GetChildren()

while true do
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 6 * 60 then
modelL.allChildren.Material.new = "Neon"
end
end
if allChildren.Material then
if game.Lightning.GetHoursAfterMidnight() == 20 * 60 then
modelL.allChildren.Material.new = "Smooth Plastic"
end
end
end


which failed and BTW GetHoursAfterMidnight does exist:
http://wiki.roblox.com/index.php?title=Making_a_Day/Night_Cycle
Last script includes it.
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:51 PM
that's GetMinutesAfterMidnight
anyway for some reason you're calling functions as constructors and you're back to game.Lightning
and you're trying to set the material of a table
and a lot of other things

Formerly ToxicDominator - add 17,509 posts
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:53 PM
Oh sorry. :)

I'm new to Lua, just started like a week ago.

And above was my old script.
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:54 PM
Updated and still not working:

model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lighting.GetMinutesAfterMidnight() == 6 * 60 then
if v:IsA("BasePart") then
v.Material = Enum.Material.Neon
elseif game.Lighting.GetMinutesAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
end
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 10:54 PM
*Actually I don't know when I started, but I know it was later in the summer
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
15 Aug 2016 10:56 PM
call GetMinutesAfterMidnight with a colon not a period

Formerly ToxicDominator - add 17,509 posts
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 11:00 PM
Hm, not working still?

model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
if v:IsA("BasePart") then
v.Material = Enum.Material.Neon
elseif game.Lighting:GetMinutesAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
end
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
15 Aug 2016 11:11 PM
Update:

model = script.Parent

for i,v in pairs (model:GetChildren()) do
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
if v:IsA("BasePart", "Union") then
v.Material = Enum.Material.Neon
elseif game.Lighting:GetMinutesAfterMidnight() == 20 * 60 then
v.Material = Enum.Material.SmoothPlastic
end
end
end

Doesn't work
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
16 Aug 2016 11:01 AM
bump
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
16 Aug 2016 11:13 AM
The output doesn't read any error messages, yet it doesn't work.
Report Abuse
addison10101 is not online. addison10101
Joined: 11 Jul 2011
Total Posts: 727
16 Aug 2016 11:50 AM
bump
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