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: Events childadded

Previous Thread :: Next Thread 
TomsGames is online. TomsGames
Joined: 11 Oct 2013
Total Posts: 1615
14 Mar 2014 07:09 PM
script.ChildAdded:connect(function(child)
print("Activated")
if child.Name == "Decal" then
addid(child)
end
end)

This is a server side script in Workspace. A child (intvalue) IS added. It just.. Does nothing.

No output at all.

What's wrong? It should be so simple :p
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Mar 2014 07:10 PM
erm,an intvalue will be named "Value" not decal..

and what is the function addid()?

please show a fuller script
Report Abuse
TomsGames is online. TomsGames
Joined: 11 Oct 2013
Total Posts: 1615
14 Mar 2014 07:11 PM
The intvalue is called "Decal" because I have a script which adds the intvalue to this script, and it names it "Decal".

This is probably wrong as it's a rough copy but I'd edit it with output usually, this is the addid function.

function addid(child)
print("Decal added")
decal = child.Value
decalid = template..tostring(decal)
print(decalid .. " will be displayed.")
table.insert(ads, #ads+1, decalid)
if start == false then
startads()
end
end
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Mar 2014 07:12 PM
Where is the child inserted into?
Report Abuse
TomsGames is online. TomsGames
Joined: 11 Oct 2013
Total Posts: 1615
14 Mar 2014 07:14 PM
Like this:

Workspace.TheScript.ChildIsHere

So it's a child of thescript :p
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Mar 2014 07:16 PM
It should work. Check the name of the value? Is the script enabled? I don't know why it wouldn't be, but the syntax is fine.
Report Abuse
TomsGames is online. TomsGames
Joined: 11 Oct 2013
Total Posts: 1615
14 Mar 2014 07:19 PM
Weird.

I'll post both scripts here then I suppose. Maybe I've mucked up somewhere!

So the script that creates the intvalue is..:

text = script.Parent.Parent.Type
ad = game.Workspace.ChangeAds

function changeboards()
if tonumber(text.Text) then
if #game:GetService("InsertService"):LoadAsset(tonumber(text.Text)):GetChildren() > 0 then
ID = game:GetService("MarketplaceService"):GetProductInfo(tonumber(text.Text))
sv = Instance.new("IntValue")
sv.Value = tonumber(text.Text)
sv.Name = "Decal"
sv.Parent = ad
end
end
end

script.Parent.MouseButton1Down:connect(changeboards)

The script (serverscript) that SHOULD read this intvalue and do stuff is this:

template = "http://www.roblox.com/asset/?id="
ads = {}
start = false
currad = 0
billboards = game.Workspace.Openme.Billboards

function addid(child)
print("Decal added")
decal = child.Value
decalid = template..tostring(decal)
print(decalid .. " will be displayed.")
table.insert(ads, #ads+1, decalid)
if start == false then
startads()
end
end

function startads()
print("Starting.")
start = true
end

while wait() do
if start == true then
print("Running while loop")
currad = currad+1
if #ads < currad then
currad = 1
end
local d = Instance.new("Decal")
if billboards.Billboard1:findFirstChild("Decal") then
billboards.Billboard1.Decal:destroy()
end
if billboards.Billboard2:findFirstChild("Decal") then
billboards.Billboard2.Decal:destroy()
end
if billboards.Billboard3:findFirstChild("Decal") then
billboards.Billboard3.Decal:destroy()
end
if billboards.Billboard4:findFirstChild("Decal") then
billboards.Billboard4.Decal:destroy()
end
if billboards.Billboard5:findFirstChild("Decal") then
billboards.Billboard5.Decal:destroy()
end
d.Texture = ads[currad]
d.Parent = billboards.Billboard1
d.Parent = billboards.Billboard2
d.Parent = billboards.Billboard3
d.Parent = billboards.Billboard4
d.Parent = billboards.Billboard5
wait(5)
end
end

script.ChildAdded:connect(function(child)
print("Activated")
if child.Name == "Decal" then
addid(child)
end
end)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Mar 2014 07:21 PM
Put the .ChildAdded event before the loop.
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