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

is there a way to make a tag gamemode, when a player touches another player they swap teams?. [closed]

Asked by
iiNogz -10
4 years ago

Im pretty new to Scripting. And i have an idea for a game like tag, when someone gets hit or goes close to another person theyre the ones whos on and it likes a loop. However, ive looked around and i have tried most things to try and script this game but i cant. Would you use teams for making this sort of gamemode or something else. If theyre is a script out there that is able to change a persons team when touched by another person that would be very useful :)

0
If say someone was the one that was on theyre on a different team to everyone else who are on the "running team" when the person who is on touches someone from the running team, the person from the running team becomes on. iiNogz -10 — 4y
0
I would not use teams, look into Object Oriented Programming for this. papasherms 168 — 4y
0
how would that help? iiNogz -10 — 4y

Closed as Not Constructive by hiimgoodpack

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

yes there is, you can listen for when the any of the player's limbs are touched, then verify if the other touching part is a player's limb, if so then get their teams and swap em.. like this

local Players = game.Players

Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait();
    local humanoid = character:WaitForChild("Humanoid");

    humanoid.Touched:Connect(onLimbTouched)
end)


function onLimbTouched(other_limb, player_limb)
    local this_player  = Players:GetPlayerFromCharacter(player_limb.Parent)
    local other_player = Players:GetPlayerFromCharacter(other_limb.Parent);

    if(other_player) then
        local other_color = other_player.TeamColor
        other_player.TeamColor = this_player.TeamColor
        this_player.TeamColor = other_color
    end
end
Ad