Hey! So im currently working on a Roblox FPS Shooter game. The Problem: The Tools are visible for the own Player, but not the Tools from other Players. So you can see the Gun with the viewmodel, but your Team-mate holds just his hand in the air with nothing in the hand.
Another Problem is, that the Script who gives the guns, is already a server Script.
Here is the Script:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
-- Leere den Rucksack bei Tod
player.Backpack:ClearAllChildren()
end)
-- Waffen aus dem WeaponRandomizer holen
local weaponRandomizer = game.ReplicatedStorage.WeaponRandomizer:GetChildren()
-- Tabellen für Primär- und Sekundärwaffen
local primaryWeapons = {}
local secondaryWeapons = {}
-- Trenne die Waffen in Primary und Secondary
for _, weapon in ipairs(weaponRandomizer) do
local classValue = weapon:FindFirstChild("Class")
if classValue then
if classValue.Value == "Primary" then
table.insert(primaryWeapons, weapon)
elseif classValue.Value == "Secondary" then
table.insert(secondaryWeapons, weapon)
end
end
end
-- Zufällige Waffen auswählen
if #primaryWeapons > 0 then
local randomizedPrimaryWeapon = primaryWeapons[math.random(1, #primaryWeapons)]:Clone()
randomizedPrimaryWeapon.Parent = player.Backpack
end
if #secondaryWeapons > 0 then
local randomizedSecondaryWeapon = secondaryWeapons[math.random(1, #secondaryWeapons)]:Clone()
randomizedSecondaryWeapon.Parent = player.Backpack
end
end)
end)
So how would the code to give the Player the gun would be?
Do i need to change this line?:
-- Zufällige Waffen auswählen
if #primaryWeapons > 0 then
local randomizedPrimaryWeapon = primaryWeapons[math.random(1, #primaryWeapons)]:Clone()
randomizedPrimaryWeapon.Parent = player.Backpack
end
if #secondaryWeapons > 0 then
local randomizedSecondaryWeapon = secondaryWeapons[math.random(1, #secondaryWeapons)]:Clone()
randomizedSecondaryWeapon.Parent = player.Backpack
end`Preformatted text`
Alright, i tried it, but it didnt changed it. Instead it gave me these errors:
Head is not a valid member of Model “Workspace.Player1”
Velocity v is nil! - Client - Spring:142
19:08:04.594 Cannot perform arithmetic due to nil values. - Client - Spring:151
19:08:08.898 RunService:UnbindFromRenderStep removed different functions with same reference name UpdateGun 2 times. - Studio
Also i spawn now in the air and fall down to the map instead of spawning to the Spawnpoint & if i have the pistol in the hand, after 3 secs it disapears. But the Primary weapon is still visible for the viewmodel but not for other players
So i did the Handle transparancy to 0 instead of 1. Now Others can see a tool in his hand. Problem: The gun from the Viewmodel should be showen there instead of this gun. Is that right, or is that not the Solution and need to change the scripts?