Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why does the other player gain pins and I don't?

Asked by 2 months ago

When I attack the other player, the other player gains pins and I don't. I want the other player to gain pins when he's attacking me and I want to gain pins when I'm attacking him. Are there any problems on this script? Thanks! ~ BlackHatRBX

local CanDamagePlayers = true 

script.Parent.Blade.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and CanDamagePlayers == true and hit.Parent.Humanoid.Health > 1 then

  local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  local pins = plr:WaitForChild("leaderstats").Pins
  pins.Value = pins.Value + 15

  hit.Parent.Humanoid:TakeDamage(script.Parent.Damage.Value)

  script.Parent.Sound:Play()

  hit.Parent.Humanoid.PlatformStand = true
  CanDamagePlayers = false
  wait(0.5)
  CanDamagePlayers = true
  wait(1)
  hit.Parent.Humanoid.PlatformStand = false
end
end)
0
Well, I think what's going on its since you're holding the tool it is touching you, which means whoever attacks will also get pins. Try checking if the hit.Name ~= tool.Parent..Parent.Name (which is the player who is holding the weopon. starmaq 657 — 2mo
0
In what line? BlackHatRBX 2 — 2mo
0
It is locating the player its hitting for the variable par not the local player aandmprogameing 38 — 2mo
0
I ment variable plr sorry aandmprogameing 38 — 2mo
0
In what line in number though? BlackHatRBX 2 — 2mo

1 answer

Log in to vote
0
Answered by 2 months ago
local CanDamagePlayers = true 

script.Parent.Blade.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and CanDamagePlayers == true and hit.Parent.Humanoid.Health > 1 then

local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local pins = plr:WaitForChild("leaderstats").Pins pins.Value = pins.Value + 15

hit.Parent.Humanoid:TakeDamage(script.Parent.Damage.Value)

script.Parent.Sound:Play()

hit.Parent.Humanoid.PlatformStand = true CanDamagePlayers = false wait(0.5) CanDamagePlayers = true wait(1) hit.Parent.Humanoid.PlatformStand = false end end)

"local plr = game.Players:GetPlayerFromCharacter(hit.Parent)" This line right here gets whatever you hit's parent not yourself. If you want yourself then you do the parent of the blade's name and then you call :GetPlayerFromCharacter. Sorry if you already figured this out, but they didn't reply to your comments

Ad

Answer this question