Hello! I have a script that is triggered from a remote event:
local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function()
local tool = game.Lighting.EMF
for _, plr in pairs(game.Players:GetPlayers()) do
coroutine.wrap(function()
local t = tool:clone()
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
print("Worked up until equip")
hum:EquipTool(t)
print("Worked equip")
end)()
end
end)
The script is located in a server script in a folder (workspace).
When it’s fired, the tool is not given to the player nor is it equipped.
coroutine.wrap(function()
local t = game.Players.PlayerName.Backpack:Clone(game.Lighting.EMF)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
print("Worked up until equip")
hum:EquipTool(t)
print("Worked equip")
local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)
local tool = game.Lighting.EMF
local t = game.Lighting.EMF:Clone().Parent(game.Players.PlayerName.Backpack)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
print("Worked up until equip")
hum:EquipTool(t)
print("Worked equip")
end)()
end
end)
local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)
local tool = game.Lighting.EMF
local t = game.Lighting.EMF:Clone().Parent = plr.Backpack
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
print("Worked up until equip")
hum:EquipTool(t)
print("Worked equip")
end)()
end
end)
Ah, thank you! It works but does not force the player to equip.
local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)
local tool = game.Lighting.EMF
local t = game.Lighting.EMF
t:Clone().Parent = plr.Backpack
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
print("Worked up until equip")
-- hum:EquipTool(t)
print("Worked equip")
end)
The script functions but gives players a tool PER player.
For example: if 2 users are in game, each user recieves two tools.
This is the script currently:
local event = game.ReplicatedStorage.EMF
event.OnServerEvent:Connect(function(plr)
local tool = game.Lighting.EMF
local t = game.Lighting.EMF
t:Clone().Parent = plr.Backpack
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
hum:EquipTool(t)
end)