Im making a gun system, and in this script for it isnt working, it doesnt shows any errors in output and i dont know what i am doing wrong
Could anyone help me?
The script
local tool = script.Parent
local shoot_part = tool:WaitForChild("FirePart")
local Workspace = game:GetService("Workspace")
local ServerStorage = game:GetService("ServerStorage")
local Attaches = game.ServerStorage:WaitForChild("Shoot")
local origin = shoot_part.Position
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
local targetPart = mouse.Target
if targetPart:WaitForChild("Humanoid") then
local hu = targetPart:WaitForChild("HumanoidRootPart")
Attaches:Clone().Parent = game.Workspace
local bullet = game.Workspace.Shoot
bullet.Attach1.Position = shoot_part.Position
bullet.Attach2.Position = hu.Position
end
end)
ReplicatedStorage is replicated to both Client and Server. Also you can’t clone from a local script, neither can you change postions. Make both a local and server script and let them communicate by remoteevents in the ReplicatedStorage.