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

How would I find or if the player has tool equipped?

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

0

So, I've been testing haven't had any luck. I'm editing my answer to show what I tried.

1

tell me if it works, my answer

1

did it work?

0

Yes thank you! I appreciate it.

1 answer

✓ Accepted answer

My all time favorite is the StringValue. You can make one StringValue in Rep Storage and in your tool, you can add this one script

local script function

function ToolEquipped() 
game.ReplicatedStorage.StringValue.Value = "Equipped"

end

function ToolUnEquipped() 
game.ReplicatedStorage.StringValue.Value = "Uneuipped"

end

script.Parent.Equipped:connect(ToolEquipped)
script.Parent.UnEquipped(ToolUnEquipped)

Server script inside serverscriptservice

local value  = game.ReplicatedStorage.StringValue

while true do
if value.Value = "Equipped" then
--code
else
--code
end

4 comments

0

Give me one minute, I just woke up. I'm going to test it then let you know if it works!

1

yes ok

0

Sweet, thanks Xyternal works great. I did some editing and I'm going to edit my question to with what I came up with just incase someone else in the future needs it.

1

anytime, my freind

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