View previous topic :: View next topic |
Author |
Message |
Nasadaws Delta Corp Moderator
Joined: 27 Mar 2008 Posts: 484 Location: Under you bed Where else?
|
Posted: Thu May 29, 2008 5:44 pm Post subject: Bomb Plant |
|
|
Could someone make me a tool that you can pick up and when you get over to a model called "Stinger" You have to hold the mouse down for 5 seconds to plant it?
Could someone make me a tool that will defuse it too?
Thanks. _________________ Nasadaws Attack Spammer: Hits 100 Damage with his Ban Hama.
Spammer: Flees.
I R NOE WELDIN ME BAN HAMAR. |
|
Back to top |
|
|
SirGelatina Site Admin
Joined: 01 Mar 2008 Posts: 116 Location: Behind you
|
Posted: Thu May 29, 2008 6:25 pm Post subject: |
|
|
Planting Bomb:
Code: | stingerParent = script.Parent.Stinger -- Remember to edit this!
isMouseDown = false
function onButton1Down(mouse)
isMouseDown = true
local hint = Instance.new("Hint")
hint.Text = "Planting Bomb..."
hint.Parent = script.Parent.Parent.Parent
wait(5)
if isMouseDown == true then
local bomb = stingerParent:clone()
bomb.Parent = game.Workspace
bomb:MoveTo(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
end
hint:remove()
end
function onButton1Up()
isMouseDown = false
end
function onSelected(mouse)
mouse.Button1Up:connect(onButton1Up)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected) |
To defuse:
Code: | timeTakenToDefuseBomb = 2 -- In Seconds
isMouseDown = false
function onButton1Down(mouse)
isMouseDown = true
if mouse.Target.Parent.Name ~= "Stinger" then return end
local hint = Instance.new("Hint")
hint.Text = "Defusing bomb..."
hint.Parent = script.Parent.Parent.Parent
local bomb = mouse.Target.Parent
wait(timeTakenToDefuseBomb)
if isMouseDown == true and bomb ~= nil then
local list = bomb:getChildren()
for x=1, #list do
if list[x].className == "Script" then list[x]:remove() end
end
wait()
bomb:remove(timeTakenToDefuseBomb * 2)
end
hint:remove()
end
function onButton1Up()
isMouseDown = false
end
function onSelected(mouse)
mouse.Button1Up:connect(onButton1Up)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected) |
|
|
Back to top |
|
|
lah30303 Beginner Poster
Joined: 10 May 2008 Posts: 11
|
Posted: Thu May 29, 2008 8:08 pm Post subject: |
|
|
In the planting script you made, right here :
wait(5)
if isMouseDown == true then
wouldn't it be better if you made it something like
wait(1)
if isMouseDown == true then
wait(1)
if isMouseDown == true then
wait(1)
if isMouseDown == true then
wait(1)
if isMouseDown == true then
wait(1)
if isMouseDown == true then
so you have to hold you mouse and you can't just click it once and again after 5 seconds?
You can probably see from this that I don't know how to script at all, but I have a general understanding of it, so I was just wondering, so If I am entirely off, just let me know. _________________ _-lah30303-_
On a quest to
learn scripting
|||||||||||||||| |
|
Back to top |
|
|
SirGelatina Site Admin
Joined: 01 Mar 2008 Posts: 116 Location: Behind you
|
Posted: Thu May 29, 2008 8:54 pm Post subject: |
|
|
Connection lines on roblox, when fired, create coroutines automatically, which means two or mone function scripts can be running in the same time. |
|
Back to top |
|
|
lah30303 Beginner Poster
Joined: 10 May 2008 Posts: 11
|
Posted: Thu May 29, 2008 9:03 pm Post subject: |
|
|
Intresting, thx for the info. _________________ _-lah30303-_
On a quest to
learn scripting
|||||||||||||||| |
|
Back to top |
|
|
Nasadaws Delta Corp Moderator
Joined: 27 Mar 2008 Posts: 484 Location: Under you bed Where else?
|
Posted: Fri May 30, 2008 7:46 am Post subject: |
|
|
It says "Planting Bomb..." and then nothing happeneds. _________________ Nasadaws Attack Spammer: Hits 100 Damage with his Ban Hama.
Spammer: Flees.
I R NOE WELDIN ME BAN HAMAR. |
|
Back to top |
|
|
|