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

How can I find a player in workspace and make a tool in their hand become visible?

I want to make it so when a player touches a part the tool in their hand becomes visible. In line 3 I want to change it so anyone can use this not just me, I want it to find the player in workspace but i'm now sure how.

game.Workspace.TheTopBun.Touched:Connect(function(hit)
	if hit.Parent:IsA("Tool") and hit.Parent.Name == "Coookedburger" then
		game.Workspace.AnimatedSL.Coookedburger.TopBun.Transparency = 0
    end
end)

1 comment

0

maybe try and find a way to detect the local player?

1 answer

✓ Accepted answer

"hit" Is supposed to be a part value not a Tool. You don't need to do that since the value will always be a basepart. But you do want to check for hit.Parent like this:

local Players = game:GetService("Players")

game.Workspace.TheTopBun.Touched:Connect(function(hit)
	local Player = Players:GetPlayerFromCharacter(hit.Parent)
	local Tool = Player.Character:FindFirstChild("Coookedburger")
	if Player and Tool then
		Tool.TopBun.Transparency = 0
	end
end)

5 comments

0

thanks but how do I make I so anyone can use it not just me?

0

Sorry I forgot to make so it changes the players tool not your character in particular. I'll edit it give me a moment.

0

That should work.

0

If my answer helped then please mark it as the answer.

0

Sorry I had to change it one last time because I forgot the character before ":FindFirstChild("Cookedburger")"

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