Making a Kill Receiver like Arsenal?

,

Yeah. This script is strange. It has components of both a local script and a server script. But what’s missing is something to get the content from the server to the player. GUIs are client side, but the server holds the information. You need a remote event to get the data from the server.

1 Like

So what does that mean? The point is like to add a uhm…Automatic Equip for the Pistol

1 Like

Well, to automatically equip a tool (A pistol is considered a tool), you would place the tool in the StarterPack.

I got looking at it again, billboard GUIs are surface GUIs which have a part as a parent (I think). I’m not sure that’s what you are looking for. You will need to use a ScreenGui with a frame and some kind of label to display information to each player, then you setup a remote event so the server can fire all clients with the information so it’s displayed to each player.

1 Like

No i meant, A Automatic Equip like arsenal, Like if you join. You will automatically given a gun

In a case like that, you clone the tool and parent the clone to the player’s character. That will equip it on the character.

Can you send me a screenshot on where to put?

Can i do it without making the Hotbar Visible?

Literally the worst way you could do damage… Literally, this is all an exploiter needs to do to kill everyone. while wait() do fireremote() end and boom everyone is dead…

Here’s some code for you (Server Side):

local serverStorage = game:GetService("ServerStorage")
local weaponsCache = serverStorage:FindFirstChild("Weapons")

-- Equip a weapon onto a player.
local function equipWeapon(player, weaponName)
	local weapon = weaponsCache:FindFirstChild(weaponName)
	if weapon == nil then
		warn("Invalid weapon name.")
		return
	end
	local playerWeapon = weapon:Clone()
	playerWeapon.Parent = player.Character
end

-- Removes an equipped weapon.
local function removeWeapon(player)
	local char = player.Character
	local weapon = char:FindFirstChildOfClass("Tool")
	if weapon == nil then
		warn("Player does not have any weapons equipped.")
		return
	end
	weapon:Destroy()
end

That’s a programmable way to equip and remove weapons to/from players. So if you want to equip all players with the same weapon, such as an M16-A3 Assault Rifle that is named “M16A3_AssaultRifle” then you do this:

local playerService = game:GetService("Players")
local weaponName = "M16A3_AssaultRifle"

for _, player in pairs(playerService:GetPlayers())
	equipWeapon(player, weaponName)
end

And that’s it. Remember, when the game is running, the player instance for all players is under game.Players when you look at Explorer in Studio, and the Character (the player’s model, avatar, etc…) will be under game.Workspace for rendering purposes. Alternatively, instead of destroying a weapon, you can set the parent of weapon to player.Backpack and the weapon will go into their inventory.

No kidding. The parameters are an exploiter’s dream because the server side event allows the CLIENT to specify the target and the damage to the target.

fireserver(target,math.huge()) and boom

1 Like

So i put A Folder in ServerStorage named “Weapons” and add a script in ServerScriptSerivce which is this one:

local serverStorage = game:GetService("ServerStorage")
local weaponsCache = serverStorage:FindFirstChild("Weapons")

-- Equip a weapon onto a player.
local function equipWeapon(player, weaponName)
	local weapon = weaponsCache:FindFirstChild(weaponName)
	if weapon == nil then
		warn("Invalid weapon name.")
		return
	end
	local playerWeapon = weapon:Clone()
	playerWeapon.Parent = player.Character
end

-- Removes an equipped weapon.
local function removeWeapon(player)
	local char = player.Character
	local weapon = char:FindFirstChildOfClass("Tool")
	if weapon == nil then
		warn("Player does not have any weapons equipped.")
		return
	end
	weapon:Destroy()
end

And where do i put this code?:

local playerService = game:GetService("Players")
local weaponName = "M16A3_AssaultRifle"

for _, player in pairs(playerService:GetPlayers())
	equipWeapon(player, weaponName)
end

Anybody know how to make a Controller Support for the game?

I tried testing it with a Controller, Everything works just fine. It’s just the Aiming, It won’t Look Left/Right/Backwards, It only looks straight.

Do you know how?

In the weapons folder, you put your actual weapons (tools) there. As for that additional code, that’s just an example. If you are using a round system, then that code would be part of the code that starts the round. If you are just placing weapons as soon as the player logs in, you can add it to the PlayerAdded event.

One thing I want to point out is that the big different between this code and just placing the weapon in the StarterPack is that the code will equip the weapon to the player while just placing it in StarterPack will just have the weapon in the player’s inventory.

1 Like

Yes I’m making a round system. So does the code part of the whole game?

I haven’t made the Gui’s for the game yet so…

Where do i put the Folder? Rep Storage? or ServerStorage?

What your talking about is a killfeed, you can just use a parent frame and have a uilistlayout handle where to place the killbar template, and whenever a player/ npc dies to another player or dummy you can just use a remote event to :FireAllClients() and send the killer’s name/ victims name

1 Like

If you are manually spawning the players, then you would place that extra code in the player.CharacterAdded event so the code will run when the player physically spawns in the game and is rendered by the engine. Due to timing constraints, which if not observed, can run the risk of a race condition. So when that event fires, I would look for the Humanoid using a WaitForChild function instead of a FindFirstChild. You will need to use the time parameter of WaitForChild. If you don’t, then it’s considered an infinite wait and will throw a warning in the console. Once that’s done, and it’s not nil, then that code can run.

Something like this:

player.CharacterAdded:Connect(function(char))
	local human = char:WaitForChild("Humanoid", 10)
	if human ~= nil then
		for _, player in pairs(playerService:GetPlayers())
			equipWeapon(player, weaponName)
		end
	end
end)

That code might not be correct since I’m doing this on the fly from memory.

As to your other question about where you put the folder, you place the weapons folder in ServerStorage. Do not place it in replicated storage because then the client will have access to your tools and might find a weakness in your code that can be exploited.

1 Like

Where do i add that @Maelstorm_1973 ?

I would place it in a module script under ServerScriptService. In fact, I would place it under this script (straight server script, not a module script):

--
-- Loads all the library modules so they are available
-- everywhere on the server.
--
for _,module in pairs(script:GetChildren()) do
	local loadMod = coroutine.create(function()
		require(module)
	end)
	coroutine.resume(loadMod)
end

This script goes directly into ServerScriptService. Then all other module scripts go under this. What this script does is that it loads all the module scripts under it and starts them off, each in their own thread, to make better use of the multithreading and multiprocessing hardware on the server.

1 Like