So Basiaclly I made this script so when ever you touch a part called Touched It gives your team 1 point and kills the player but the thing is sometimes its adding points automaticlly and also It's not killing the player please make it verify that the player who touched it has humanoid I forgot how to
game.Workspace.Touch.Touched:Connect(function(player)
if player.Touched then
game.Workspace.RedPoint.Value = game.Workspace.RedPoint.Value + 1
player.character.Humanoid.Health = 0
end
end)
The only reason why your script isn't working is because you're passing the wrong parameter to Touched
's argument. The argument that Touched
passes is the part that touched the part that is firing the Touched
event.
Here's a simple fix:
local function AddAndKill(part) local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent) -- This is the player if player then workspace.RedPoint.Value = workspace.RedPoint.Value + 1 player.Character.Humanoid.Health = 0 end end workspace.Touch.Touched:Connect(AddAndKill)