How would I go about making weapons for my game

Hello I am working on a murder mystery style game and as we all know a game like that requires weapons…

I got my weapons that are going to be used in replicated storage in a folder called Items each weapons has a main handle and than the model itself as shown in this picture

Click Here

right now i have a server script called DamageHandler which manages the killing aspect of the knife and than I have a local script called KnifeHandler which manages when the knife is equipped/unequipped and also when a player uses it as well as a RemoteEvent called “StabEvent” but with all the knifes I have in my game it’s kind of a pain to use the same two scripts and paste them into each knife

I understand that games like assassin use a module script that holds the ( name, imageID, rarity, color) to sort out the information of each knife

what im getting at is I am trying to make a system similar to assassin but I am not too sure how to come about this

here are the current scripts

Knife Handler (local script)
local HoldAnim = game.ReplicatedStorage.Animations:WaitForChild("Hold_Animation")
local ThrowAnim = game.ReplicatedStorage.Animations:WaitForChild("Throw_Animation")
local StabAnim = game.ReplicatedStorage.Animations:WaitForChild("Stab_Animation")

local ThrowSound = game.ReplicatedStorage.Sounds:WaitForChild("Knife_Throw")
local StabSound = game.ReplicatedStorage.Sounds:WaitForChild("Knife_Slash")

local Knife = script.Parent

local MouseService = game:GetService("MouseService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local plrMouse = player:GetMouse()

local StabEvent = game.ReplicatedStorage.Remotes:WaitForChild("Stab")


Knife.Equipped:Connect(function()
	local HoldTrack = script.Parent.Parent.Humanoid:LoadAnimation(HoldAnim)
	HoldTrack:Play()
	
	Knife.Unequipped:Connect(function()
		HoldTrack:Stop()
	end)
end)

Knife.Activated:Connect(function()
	local StabTrack = script.Parent.Parent.Humanoid:LoadAnimation(StabAnim)
	StabTrack:Play()
	StabSound:Play()
	task.wait(1)
	StabEvent:FireServer()
end)```
Damage Handler (Server Script)
local CanStab = true
local StabEvent = game.ReplicatedStorage.Remotes:WaitForChild("Stab")

local DebounceTable = {}

local HoldingAnim = game.ReplicatedStorage.Animations:WaitForChild("Stab_Animation")

local hitbox = script.Parent:WaitForChild("Hitbox")



StabEvent.OnServerEvent:Connect(function()
	script.Parent:WaitForChild("Hitbox").Touched:Connect(function(objectThatTouchesTheHitbox)
		if objectThatTouchesTheHitbox.Parent then
			if objectThatTouchesTheHitbox.Parent:FindFirstChild("Humanoid") then
				if DebounceTable[objectThatTouchesTheHitbox.Parent] == true then return end
				DebounceTable[objectThatTouchesTheHitbox.Parent] = true
				objectThatTouchesTheHitbox.Parent.Humanoid:TakeDamage(100)
				print("Knife Hit: ".. objectThatTouchesTheHitbox.Parent.Name)
				task.wait(0.5)
				DebounceTable[objectThatTouchesTheHitbox.Parent] = nil
			end
			end
		end)
	end)





any help or advice would be much appreciated

Don’t add the scripts to each knife. Have a look at the collection service and use attributes to give the knives different stats.

mmmmmmm, so you want to figure out how to set up your knives so that you can attack/throw with them?

i’m not 100% sure about setting up the m1/throwing connections with the knife, but the framework would be that when you m1/throw on the client, you request to do so on the server w/ a remote event that validates that request (to prevent cheating) and the server will run the hitbox/knife throw stuff. on the client make sure to play the animation for knife swing/throw right as you send that remote event since it’ll create a responsive feel w/ zero security implications since it’s just playing animations

tldr; set up a local script on the client that sets up the weapon connections whenever you receive a knife, handles the animation playing, and sends attack requests to the server when you use the knife (for security). the server just handles security and hitbox handling alongside damaging people hit by you.

for M1s it maaaay be best if you set up the hitboxes on your client and then tell the server if you hit someone, where the server would then check if you were even facing the victim and if you were close enough (so that your hitboxes feel smooth for the murderer) before verifying the damage/kill.

do NOT do this for throwing, though, since it’s kind of hard to even verify if someone spoofed a fake throw hit detection. knife throwing should remain server sided.

2 Likes