Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 07 Dec 2015 07:41 AM |
Im trying to make a dodgeball that youre able to pickup using its clickdetector, but once its picked up, the click detector is parented to nil and the dodgeball will be by your hand. Using getmouse, you click using button1down to release the dodgeball, then I disconnect the button1down event. It aint working properly, im pretty confused as to how the outline would look like. Heres my draft:
local ball = script.Parent -- Ball local cd = script.Parent.ClickDetector local owner = script.Parent.Owner -- StringValue local click = 0
cd.MouseClick:connect(function(plyr) if (click == 0) then owner.Value = plyr.Name cd.Parent = nil print(click) click = click + 1 print(click) elseif (click == 1) then local mouse = plyr:GetMouse() local con con = mouse.Button1Down:connect(function() print('fire') click = 0 cd.Parent = ball con:disconnect() end) end end)
Problem, it never print 'fire.' |
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
| |
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 07 Dec 2015 07:47 PM |
I know you'd have to click the click detector again to activate the second part of code, but I'm confused as to how I can activate the Button1Down event without clicking the click detector more than once.
|
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 07 Dec 2015 08:19 PM |
Bump.
Also I'm trying to get it in this order:
Click click detector Click detector is nil Value changes to clickers name (Imaginary for now) ball will be held by player GetMouse is used to make the player use the Button1Down event Player clicks once, (imaginary) ball is released Click detector is parented back to ball Button1Down is disconnected |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 08:37 PM |
You can not get a player's input using a server script (i.e GetMouse() and UserInputService)
#code Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs) |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 09:00 PM |
| I don't know if this is your problem but try not having two word variables like con con |
|
|
| Report Abuse |
|
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 07 Dec 2015 09:45 PM |
local ball = script.Parent -- Ball local cd = ball.ClickDetector -- id change this to Instance.new; local owner = ball.Owner -- StringValue local click = 0
cd.MouseClick:connect(function(plyr) if (click == 0) then owner.Value = plyr.Name cd:Destroy(); -- just destroy it, this script will run again when it enters workspace cd = nil; print(click) click = click + 1 print(click) elseif (click == 1) then -- this whole section is crap because this a global script. You need to make a local script and put it in every client, and use player.CharacterAdded:connect(function(C)C.ChildAdded:connect(function(Child) local mouse = plyr:GetMouse() local con con = mouse.Button1Down:connect(function() print('fire') click = 0 cd.Parent = ball con:disconnect() end) end end)
|
|
|
| Report Abuse |
|
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 07 Dec 2015 09:46 PM |
| Second thought, it might not run again when it enters workspace. But the client script can make it run again. |
|
|
| Report Abuse |
|
|