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: Why wont this work?

Previous Thread :: Next Thread 
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:08 PM
function onButton1Down(mouse)
hit = mouse.Target
local debounce = false

if hit == nil then return end
if (hit.Position - game.Players.LocalPlayer.Character.BlueTroops.Head.Position).magnitude < 7 then
if debounce == false then
local check = hit.Parent:findFirstChild("Health")
if check == nil then return end
debounce = true
Check.Value = Check.Value - script.Parent.Parent.Parent.Character.BlueTroops.Damage.Value
script.Parent.Parent[".:Main:."].XP.Value = script.Parent.Parent[".:Main:."].XP.Value + 2
script.Parent.Parent[".:Main:."].Points.Value = script.Parent.Parent[".:Main:."].Points.Value + 5
script.Parent.Name = ".:Attack :."
wait(5)
debounce = false
script.Parent.Name = ".:Attack:."
end
end
end

function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

script.Parent.Selected:connect(onSelected)
Report Abuse
Hopslop is not online. Hopslop
Joined: 11 May 2008
Total Posts: 3795
25 Jan 2009 01:11 PM
This should work:

function onButton1Down(mouse)
hit = mouse.Target
local debounce = true

if hit == nil then return end
if (hit.Position - game.Players.LocalPlayer.Character.BlueTroops.Head.Position).magnitude < 7 then
if debounce == false then
local check = hit.Parent:findFirstChild("Health")
if check == nil then return end
debounce = true
Check.Value = Check.Value - script.Parent.Parent.Parent.Character.BlueTroops.Damage.Value
script.Parent.Parent[".:Main:."].XP.Value = script.Parent.Parent[".:Main:."].XP.Value + 2
script.Parent.Parent[".:Main:."].Points.Value = script.Parent.Parent[".:Main:."].Points.Value + 5
script.Parent.Name = ".:Attack :."
wait(5)
debounce = false
script.Parent.Name = ".:Attack:."
end
end
end
end

function onSelected(mouse)
mouse.Button1Down:connect(function() onButton2Down(mouse) end)
end

script.Parent.Selected:connect(onSelected)
Report Abuse
level140roblox is not online. level140roblox
Joined: 08 Jun 2008
Total Posts: 9577
25 Jan 2009 01:13 PM
j00 forgot an end
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:13 PM
No i didnt if you look it says "return end"
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:17 PM
BumpO
Report Abuse
level140roblox is not online. level140roblox
Joined: 08 Jun 2008
Total Posts: 9577
25 Jan 2009 01:18 PM
j00 needed to end the function.

you ended all the if's
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:19 PM
I have ended the function along with the 2 ifs which needed an end.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
25 Jan 2009 01:21 PM
level, you're wrong. Just face it. ^_^




local debounce = false
function onButton1Down(mouse)
hit = mouse.Target

if hit == nil then return end
if (hit.Position - game.Players.LocalPlayer.Character.BlueTroops.Head.Position).magnitude < 7 then
if debounce == false then
debounce = true
local check = hit.Parent:findFirstChild("Health")
if check == nil then return end
debounce = true
Check.Value = Check.Value - script.Parent.Parent.Parent.Character.BlueTroops.Damage.Value
script.Parent.Parent[".:Main:."].XP.Value = script.Parent.Parent[".:Main:."].XP.Value + 2
script.Parent.Parent[".:Main:."].Points.Value = script.Parent.Parent[".:Main:."].Points.Value + 5
script.Parent.Name = ".:Attack :."
wait(5)
debounce = false
script.Parent.Name = ".:Attack:."
end
end
end

function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

script.Parent.Selected:connect(onSelected)





Try that.
Report Abuse
level140roblox is not online. level140roblox
Joined: 08 Jun 2008
Total Posts: 9577
25 Jan 2009 01:22 PM
grrr i only saw 1 return end...

I didn't fully read it, what was wrong?
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:22 PM
Ty agent ill try now. Its ok level.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
25 Jan 2009 01:22 PM
I have no clue. >_>

I do know he was setting debounce to false every time he clicked. I fixed that, though.
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:30 PM
Nope didnt work =(
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:31 PM
For such a simple hopperbin its really hard to fix -__-"
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
25 Jan 2009 01:31 PM
local debounce = false
function onButton1Down(mouse)
hit = mouse.Target

if hit == nil then return end
if (hit.Position - game.Players.LocalPlayer.Character.BlueTroops.Head.Position).magnitude < 7 then
if debounce == false then
debounce = true
local Check = hit.Parent:findFirstChild("Health")
if Check == nil then return end
debounce = true
Check.Value = Check.Value - script.Parent.Parent.Parent.Character.BlueTroops.Damage.Value
script.Parent.Parent[".:Main:."].XP.Value = script.Parent.Parent[".:Main:."].XP.Value + 2
script.Parent.Parent[".:Main:."].Points.Value = script.Parent.Parent[".:Main:."].Points.Value + 5
script.Parent.Name = ".:Attack :."
wait(5)
debounce = false
script.Parent.Name = ".:Attack:."
end
end
end

function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

script.Parent.Selected:connect(onSelected)
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 01:41 PM
Would it maske any difference if the thing you are clicking is in someones character?
Report Abuse
bow5 is not online. bow5
Joined: 09 Nov 2007
Total Posts: 2077
25 Jan 2009 01:51 PM
Ajent that one dident work ethier I was testing it with cymru
Report Abuse
LegoConqueror is not online. LegoConqueror
Joined: 07 Jan 2009
Total Posts: 1289
25 Jan 2009 01:52 PM
Are you using a LocalScript?
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 02:00 PM
Yes i am
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 02:04 PM
BuMpIo
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
25 Jan 2009 02:24 PM
If you need my help, I need you to make everything a free model, including the script that put the BlueTroops, and everything in the player. I need all scripts, and all models in a free model. If you don't care for my help, then nvm.
Report Abuse
cymru792 is not online. cymru792
Joined: 28 Jan 2008
Total Posts: 2803
25 Jan 2009 02:26 PM
Ok wait there then roberto
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