Im developing a game and i needed to be able to control the spawn of a player, so i disable the characterautoload and added a script to the sss:
local Players = game:GetService("Players")
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
end
player.CharacterAdded:Connect(onCharacterAdded)
player:LoadCharacter()
end
Players.PlayerAdded:Connect(onPlayerAdded)
everything works, except this script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local weaponModule = require(ReplicatedStorage.Modules.WeaponModule)
game.Players.PlayerAdded:Connect(function(player)
print("Player Found")
player.CharacterAdded:Connect(function(character)
print("Character Found")
character.ChildAdded:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("Shoot") then
local tool = child
local shootEvent = tool:WaitForChild("Shoot")
if shootEvent then
print("event found")
end
shootEvent.OnServerEvent:Connect(function(player, mousePosition)
print("shot event from server fired")
weaponModule.Shoot(player, tool, mousePosition)
end)
end
end)
end)
end)
it stops at the player found print, so my guess is that there’s something wrong with the character load. The thing is that the script works sometime, and some time not, so my other guess it has to do with the loading order?
Idk how to fix this, pls help me.