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

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

Asked by 4 years ago

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)
0
maybe try and find a way to detect the local player? Jakob_Cashy 79 — 4y

1 answer

Log in to vote
0
Answered by
Narunzo 172
4 years ago
Edited 4 years ago

"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)
0
thanks but how do I make I so anyone can use it not just me? AnimatedSL -3 — 4y
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. Narunzo 172 — 4y
0
That should work. Narunzo 172 — 4y
0
If my answer helped then please mark it as the answer. Narunzo 172 — 4y
0
Sorry I had to change it one last time because I forgot the character before `":FindFirstChild("Cookedburger")"` Narunzo 172 — 4y
Ad

Answer this question