I think I am learing how to script (Sort of the realy basics)
#1
RockFolder = create("Model")
RockFolder.Name = "Rocks"
RockFolder.Parent = game.World

link(RockFolder.ChildAdded,function(Stone)
link(Stone.Collided,function (hit)
if hit.Parent:isA("Character") and hit.Parent.Name ~= script.Parent.Parent.Parent.Name then
hit.Parent.Health = hit.Parent.Health-100
hit.Velocity = Vec2D(0,math.random(125,150))
end
end)
for i=1,25 do
Stone.Position = Stone.Position:add(Vec2D(0,0.4))
sleep(0.01)
end
sleep(0.05)
for i=1,25 do
Stone.Position = Stone.PositionConfusedub(Vec2D(0,0.4))
sleep(0.01)
end
local s = create("Script")
s.Source = "sleep(3) script.Parent:remove()"
s.Parent = Stone
end)

function Stone(Pos,Number)
S = create("Box")
--S = create("Box")
S.Name = "Rock"
--S.Fixed = true
--S.Locked = true
S.Transparency = 0.0
S.Collidable = true
S.Size = Vec2D(math.random(2,7),math.random(20,25))
S.Color = Color(148, 83, 17)
S.Position = Pos:add(Vec2D(Number*10,0))
S.Parent = RockFolder
end

D = false

link(script.Parent.MouseDown,function()
if D == true then return end
D = true
local BP = Vec2D(script.Parent.Parent.Parent.Character.Body.Position.x,script.Parent.Parent.Parent.Character.Body.Position.y)
for i=1,10 do
Stone(BP,i*-1)
sleep(0.05)
end
D = false
end)


It was origonaly water. I have never edited a script (Well... But Person299 Admin commands on ROBLOX. LOL) So I thought If I made Water into Box, a soild box would appear instead of water, it was right, then I changed the color and Transparenty! Big Grin Looking at Qwertygiy's ROBLOX Scripts, he studyed Scripts to learn, like I am doing. So if anyone can give me basic scripts to edit, Thanks. Smile
P.s, this script was from Anti.
Reply
#2
Exactly. Here's some extra code bits to help you out, and a script that uses them:

while true do: This is a loop. It will repeat until instructed to "break".

[lua]
count = 0
while true do
sleep(1)
print("Looping.")
count = count + 1
if count > 10 then
break
end
end
[/lua]

It loops 10 times, printing "Looping" each time, then stops.

stuff:getChildren(): Gets a table with all the members being the descendents of stuff.

for q = 1, #table do: Loops through each member of table 'table'. q can be any letter. I use q because it's the first letter in the keyboard.

[lua]
local itemz = game.World:getChildren()
for q = 1, #itemz do
if itemz[q]:isA("Character") then
itemz[q].Body.Velocity = Vec2D(0,200)
end end
[/lua]

Makes everyone jump high Big Grin
Reply
#3
(05-14-2011, 10:20 PM)Qwertygiy Wrote: Exactly. Here's some extra code bits to help you out, and a script that uses them:

while true do: This is a loop. It will repeat until instructed to "break".

[lua]
count = 0
while true do
sleep(1)
print("Looping.")
count = count + 1
if count > 10 then
break
end
end
[/lua]

It loops 10 times, printing "Looping" each time, then stops.

stuff:getChildren(): Gets a table with all the members being the descendents of stuff.

for q = 1, #table do: Loops through each member of table 'table'. q can be any letter. I use q because it's the first letter in the keyboard.

[lua]
local itemz = game.World:getChildren()
for q = 1, #itemz do
if itemz[q]:isA("Character") then
itemz[q].Body.Velocity = Vec2D(0,200)
end end
[/lua]

Makes everyone jump high Big Grin

Big Grin Thanks. I am also hosting a sever. http://buildism.net/game.php?id=4582 :3 Feel free to join.
Reply
#4
(05-14-2011, 10:20 PM)Qwertygiy Wrote: Exactly. Here's some extra code bits to help you out, and a script that uses them:

while true do: This is a loop. It will repeat until instructed to "break".

[lua]
count = 0
while true do
sleep(1)
print("Looping.")
count = count + 1
if count > 10 then
break
end
end
[/lua]

It loops 10 times, printing "Looping" each time, then stops.

stuff:getChildren(): Gets a table with all the members being the descendents of stuff.

for q = 1, #table do: Loops through each member of table 'table'. q can be any letter. I use q because it's the first letter in the keyboard.

[lua]
local itemz = game.World:getChildren()
for q = 1, #itemz do
if itemz[q]:isA("Character") then
itemz[q].Body.Velocity = Vec2D(0,200)
end end
[/lua]

Makes everyone jump high Big Grin

DO NOT ACT LIKE WHILE TRUE DO IS A SEPERATE KIND OF LOOP!!!!!!!!!!!!!!!!!!!
Teach them what the while loop is then tell them how while true do is a loop that repeats forever, and how "break" exits a loop
[Image: 5widdh.png]
Siggy by McNoobster!
[Image: loading.gif]
Reply
#5
Scripting forum?
[Image: chaosthegreat.png]
Reply
#6
(05-14-2011, 10:20 PM)Qwertygiy Wrote: [lua]
count = 0
while true do
sleep(1)
print("Looping.")
count = count + 1
if count > 10 then
break
end
end
[/lua]

Why not just do:

[lua]
count = 0
while count <= 10 do
print("Looping.")
count = count + 1
end
[/lua]
Reply
#7
Because that works in this case, but it only works if count <= 10 when the loop starts.

It's easier when just beginning to do something that will always work than try to figure out which way to do it (especially when editing an existing, usually long, script).
Reply
#8
(05-14-2011, 10:55 PM)Qwertygiy Wrote: Because that works in this case, but it only works if count <= 10 when the loop starts.

>_>

That's why you explicitly say "count = 0" in the beginning...
Reply
#9
Scripting Mumbo-Jumbo O.o
Reply
#10
Woah, you guys are codemasters. I suck at scripting!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)