DanPai
|
  |
| Joined: 03 Jun 2016 |
| Total Posts: 355 |
|
|
| 18 Jun 2017 02:15 PM |
I just started scripting about two months ago, so I'm not really good at it. Anyway, I am trying to make it so that when a player clicks on another, the player that was clicked on takes damage.
I have this script but it's most likely completely wrong.
mousey = game.Players.LocalPlayer:GetMouse() hum = mousey:FindFirstChild("Humanoid")
--
function Attack() if mousey.Target == hum then hum:TakeDamage(50) end end
--
mousey.Button1Down:connect(function(Attack) end)
|
|
|
| Report Abuse |
|
|
Crxsh
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 7152 |
|
|
| 18 Jun 2017 02:17 PM |
Wrong forum, go to 'Scripting' for help on this.
why u asken all dem questions? |
|
|
| Report Abuse |
|
|
ParaText
|
  |
| Joined: 15 Aug 2016 |
| Total Posts: 799 |
|
|
| 18 Jun 2017 02:26 PM |
Mouse is doesn't have any yield functions so :FindFirstChild() is completely out of place
First, you have to get what the mouse is pointing to, the exact part/model, with Mouse.Target
Next, check if the the target is actually a player's character, and if so, make sure that the character has a humanoid in it: if players:FindFirstChild(mouse.Target) then if mouse.Target:FindFirstChild("Humanoid") local hum = mouse.Target.Humanoid hum.Health = hum.Health - DAMAGE_TAKEN and then subtract the damage from the humanoid's health also make sure you use a debounce so that people can't spam click
local debounce = false if players:FindFirstChild(mouse.Target) and not debounce then if mouse.Target:FindFirstChild("Humanoid") debounce = true local hum = mouse.Target.Humanoid hum.Health = hum.Health - DAMAGE_TAKEN wait(TIME_TO_WAIT) debounce = false
|
|
|
| Report Abuse |
|
|