Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script to find if player has tool equipped not working?

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

1 comment

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.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.