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

Script to find if player has tool equipped not working?

Asked by 5 years ago
Edited 5 years ago

Hi, I was working on getting this script to send a notification to the player whenever one of the hunter has a spectate tool equipped. I'd like to keep it a localscript.

repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(workspace)     
local Character = game.Players.LocalPlayer.Character

function CHECK_TOOL(character)
    for _, v in pairs(character:GetChildren()) do
        if v:IsA("Spectate") then
            game:GetService("StarterGui"):SetCore("SendNotification", {
    Title = "Spectate Detected!";
    Text = "Hide!";
})
            end
        end
    end
0
I'd send the notification every time the hunter equips the spectate tool. https://developer.roblox.com/en-us/api-reference/class/Tool also if you are wanting to send a notification to all players from a local script then you need to look into remote events/functions. ForeverBrown 356 — 5y

1 answer

Log in to vote
0
Answered by
qChaos 86
5 years ago
Edited 5 years ago

It's because "Spectate" isn't a class, IsA checks the class/instance type of an object. Instead, do: if v.Name=='Spectate' and v:IsA'Tool' then

Ad

Answer this question