What I would like to know is how would I be able to get a player's humanoid and store into a variable when the player has activated a tool in their starter pack such as: shooting a gun, lunging a sword, dropping a bomb.
COMMUNITY QUESTION
How Would I get a player's humanoid when the player has clicked to activate a tool?
1 answer
This is a broad topic, so I will give you an example.
SETUP
Create a server script under server script service
Create a bindable event under replicated storage
-Name it "ToolActivated"
Create a script under each tool you want to detect the activation on
SCRIPTING
Step 1 server script:
ev = game:GetService("ReplicatedStorage"):WaitForChild("ToolActivated")
playersActivated = {}
ev.Event:Connect(function(plrName)
local InTable = false
for _,v in pairs(playersActivated) do
if v == plrName then
InTable = true
end
end
if InTable == true then return end
table.Insert(playersActivated,plrName)
end)
while wait(10) do --This just prints who has activated a tool every 10 seconds
local PLRstring = ""
for i,v in pairs(playersActivated) do
if i == #playersActivated then
PLRstring = PLRstring..v
else
PLRstring = PLRstring..v..", "
end
end
print("The following players have activated a tool: "..PLRstring
end
Step 3 EACH server script:
EV = game:GetService("RepliactedStorage"):WaitForChild("ToolActivated")
tool = script.Parent
tool.Activated:Connect(function()
EV:Fire(tool.Parent.Name)
end)
I hope my answer helped! ~mc3334
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Connect a table to an activation event using .Character
Not helpful, nor does it make any sense at all...