Hey scriptinghelpers, I'm working on a tool. So the touch is fine everything works but, I'm trying to add or if the player has the tool equipped then to this function (or something like it similar doesn't have to be an if then statement). I don't really know how I would do this or, where I would put this.
This is a script inside of a Handle(part), handle is inside of a tool.
--I have other scripts that give the tool away so, it's constantly changing.
function onTouch(part)
local character = part.Parent
local player = game.Players:GetPlayerFromCharacter(character)
script.Parent.BrickColor = player.TeamColor
script.Parent.Value.Value = player.TeamColor
end
script.Parent.Touched:Connect(onTouch)
Thanks for the help in advance! I appreciate it.
Thanks Xyternal for the solution! Here's my script I ended up with.
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
function toolEquipped()
game.ReplicatedStorage.StringValue.Value = "Equipped"
game.ReplicatedStorage.BrickColorValue.Value = player.TeamColor
end
function toolUnequipped()
game.ReplicatedStorage.StringValue.Value = "Unequipped"
end
script.Parent.Equipped:Connect(toolEquipped)
script.Parent.Unequipped:Connect(toolUnequipped)

4 comments
So, I've been testing haven't had any luck. I'm editing my answer to show what I tried.
tell me if it works, my answer
did it work?
Yes thank you! I appreciate it.