So, im making an item placement system, and i am moving a model from the replicatedstorage to the workspace, but for some reason, the script stops working.
AI Code:
local firerate = 0.225--in seconds
local damage = 1
wait(1)
--gunfire
if script.Parent.Parent == workspace then
while true do
wait(firerate)
local a = workspace:WaitForChild("Normal")
script.Gunshot:Play()
a:Remove()
end
end
Movement Code:
wait(0.01)
--Variables
local a = game.ReplicatedStorage.MachineGunner
--MainScript
c = game.Workspace.Course.Scenery.Placement1.TowerPlace
c.MouseClick:Connect(function()
game.ReplicatedStorage.MachineGunner.Parent = workspace
local b = game.Workspace.MachineGunner
b:SetPrimaryPartCFrame(CFrame.new(workspace.Course.Scenery.Placementpos1.Position + Vector3.new(0,0,0)))
b.MachineGun.Bipod.Transparency.Transparency = 0
end)

8 comments
What script doesnt work Ai code or movement code?
well the AI code will break when i try to move it from ReplicatedStorage to Workspace
So what I assume your trying to do is to move an ai?
well no, I'm trying to get a Defender/Tower and moving it to that specific place(that part works) but then, I try to move it to the workspace, but then the AI wont shoot, yet when if i don't have it in replicatedstorage it works just fine
Thats because replicated storage is a storage used to as the name suggests replicate objects client/server sided thats why it doesnt work because npc cant run client sided.
no it doesnt run inside replicatedstorage
it begins running when inside workspace
Thats what I said npc cant run in replicated storage because its both client sided and server sided but it works in workspace