Tworzenie broni w Roblox

Stwórz Tool o nazwie Gun.
Wewnątrz Gun:
– dodaj model 3D
– dodaj Part o nazwie Handle i ustaw w miejscu rękojeści
– dodaj WeldConstraint i połącz model 3D z Handle
– dodaj RemoteEvent
– dodaj localScript o nazwie np. GunLocal
– dodaj Script o nazwie, np. GunServ
– dodaj plik audio z dzwiekiem wystrzalu o nazwie, np. Shot
– wewnątrz modelu 3D dodaj Attachment o naziw np. MuzzleAtt, a do niego dodaj efekt cząsteczek (Particle Emitter) o nazwie, np. MuzzleEffect

GunLocal

--gun local script
local gun = script.Parent
local remoteEvent = gun:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local coolDown = true
local coolDownTime = 0.1

gun.Activated:Connect(function()
	if coolDown then
		coolDown = false
		local target = mouse.Target
		local hum = target.Parent:FindFirstChild("Humanoid")
		gun.Shot:Play()
		gun.Gun.MuzzleAtt.MuzzleEffect:Emit(1)
		if hum then
			remoteEvent:FireServer(target.Parent)
		end
		wait(coolDownTime)
		coolDown = true
	end
end)

GunServ

local remoteEvent = script.Parent.RemoteEvent
local gunDamage = 20

remoteEvent.OnServerEvent:Connect(function(player, target)
	target.Humanoid.Health -= gunDamage
end)


Scroll to Top