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)
The reason your code didn't work was because it can't run in replicated storage because replicated storage runs both client and server sided so essentially the client side breaks the request from the server replicated storage is used for remote event s,Bindable function etc. So to conclude it don't put things in replicated storage only for things that you want both client and server to interact with.
Also to move AI/NPC use the service pathfinding. It's more efficient.
To learn about Replicated Storage and Pathfinding click the links.