Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tag script is not killing on touch at all?

Asked by 4 years ago

Hi, I have a tag game and the script that I use just does not work at all. It prints the player but the script just won't break joints. The tagger team color is "Really Red"

script.Parent.Handle.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    print(player)
    if player and not player.TeamColor == BrickColor.new("Really red") then
        hit.Parent:BreakJoints()
    end
end)

PLEASE HELP!

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Super simple fix. Instead of doing all of that, you can just easily kill the player.

Code:

local Handle = script.Parent.Handle --reference variable for the handle
local Player = game.Players.LocalPlayer --reference variable for your player

Handle.Touched:Connect(function(Hit) --if the handle gets touched, assign the touched thing to Hit
    local Humanoid = Hit.Parent:FindFirstChild("Humanoid") --sets Humanoid equal to the humanoid
    Humanoid.Health = 0 --sets the humanoid health to 0, if touched

    if Hit.Parent == Player then --if the parent is your localplayer, then (basically so it doesnt kill you)
        return --return, which basically ignores everything else, and reruns
    end
end)

I tested this, and it worked. Hopefully you understand the code, and have a good day.

0
You forgot to mention the team. So, 'if player.Team ~= game.Teams.["YOURTEAMNAME"] then'. Just adding to your post since I realized you forgot that. uhi_o 417 — 4y
0
I edited it to fit some more, and added the team. Thank you so much! Dax009YT 6 — 4y
0
No problem. gamernight687 138 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Have you tried to put the Humanoid's health to 0?

0
Still doesn't work. Dax009YT 6 — 4y

Answer this question