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

How would I detect flag captures?

Asked by 9 years ago

Leaderboard Script

local stats = {"value", "Omegite"}

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    for _, stat in pairs(stats) do
        Instance.new("IntValue", leaderstats).Name = stat
    end
end)

Take this as a question and not a request. I would like to detect when a red or blue team member captures the flag and adds a point to a intvalue which is in workspace. What events would I use to detect when someone has captured a flag? FYI: The game I have makes you spawn in a lobby and picks a map after 25 seconds of waiting in the lobby.

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Just use a touched event on the capture platform, then see if they're holding the enemy flag (which I assume is being placed in your character.) From there, you can change the value in workspace. Something like,

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("EnemyFlag") then
        workspace.IntValue.Value = workspace.IntValue.Value + 1
    end
end

Of course, if you don't have a way of respawning the flag, this will run multiple times and give too many captures.

Ad

Answer this question