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

How do you assign a collectionservice tag with the local player?

Asked by 4 years ago

I'm working on a game where if you pull out your weapon, soldiers will automatically attack you. I'm using the Roblox Free Model: Rthro Soldier. So after evaluating the scripts, it listed that it will attack based on if a player has the tag "SoldierEnemy". Here's what I have so far.

local Tool = script.Parent
local CollectionService = game:GetService("CollectionService")
local player = game.Players.LocalPlayer

Tool.Equipped:Connect(function(mouse)
    print("ToolEquip")
    CollectionService:AddTag(player, "SoldierEnemy")
end)

This is a localscript within the gun. If anyone could clear up the problem, that would be greatly appreciated!

Answer this question