it falls on the ground but i think i need to make it a server script but the problem is that idk how to do that cuz i tried doing that by changing the localplayer to the player added event and didnt work
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local sword = ReplicatedStorage:WaitForChild("Sword")
Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local swordClone = sword:Clone()
humanoid:EquipTool(swordClone)
end)
Don’t know, haven’t worked with tools.
This is the entire script you need. Put this in ServerScriptService and you should be good, I think.
local plr = game.Players.PlayerAdded:Connect(function()
local Teams = game:GetService("Teams")
wait(1)
if plr.Team == Teams.Spys then
plr.Character.Humanoid:EquipTool(game.ReplicatedStorage.Sword:Clone())
end
end)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")
local sword = ReplicatedStorage:WaitForChild("Sword")
Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
if player.Team == Teams.Spys then
local humanoid = character:WaitForChild("Humanoid")
local swordClone = sword:Clone()
humanoid:EquipTool(swordClone)
end
end)
That’s everything you need in one single script in ServerScriptService.
Also, don’t use wait(). Apart from it being deprecated soon, you can simply yield the function until the character loads in using CharacterAdded:Wait().
If you want to yield, use task.wait(). It’s more accurate and it servers to yield the thread, not the entire script.