I have a Scud missile system that I am working on, and it works well, but after a certain range the missile just freezes/pauses, as seen below:
sometimes I get the beyond range warning message, sometimes I don’t.
Now what doesn’t make sense is, I use this exact same system for a different missile launcher in my game, that being the battleship system seen below:
As you can see, I can guide the missile to the other side of the map quite easily without having issues with StreamingEnabled.
Why is this happening? The Scud system uses almost the same code as the battleship missiles. Attached is the important parts:
---- server side
local missile:Model = actualScud:FindFirstChild("missile",true)
local effect:MeshPart = actualScud:FindFirstChild("effect",true)
local weld = missile.PrimaryPart:FindFirstChild("delete")
if not missile then return end
if weld then
weld:Destroy()
end
effect:Destroy()
task.wait()
missile.Parent = occupant
task.wait(0.5)
missile.PrimaryPart:SetNetworkOwner(plr)
local particle = missile.PrimaryPart:FindFirstChildWhichIsA("ParticleEmitter",true)
if particle then
particle.Enabled = true
end
local sfx = missile.PrimaryPart:FindFirstChildOfClass("Sound")
if sfx then
sfx:Play()
end
if plr.Character then
plr.Character.PrimaryPart = missile.PrimaryPart
end
return missile
---client
local missiles:Folder = script.engine.Value
local event = missiles:FindFirstChildOfClass("RemoteFunction")
local plr = game:GetService("Players").LocalPlayer
local camera = workspace.Camera
local click:RBXScriptConnection = nil
local mouse = plr:GetMouse()
local uis = game:GetService("UserInputService")
local function pickMissile()
if click ~= nil then
click:Disconnect()
end
--print("ping1")
local pickedMissile:Model = event:InvokeServer() -- checks to see if there's a valid missile, returns it
if pickedMissile then
local speed = pickedMissile.PrimaryPart:FindFirstChildWhichIsA("LinearVelocity",true)
local pos = pickedMissile.PrimaryPart:FindFirstChildWhichIsA("AlignOrientation",true)
pos.Enabled = true
speed.Enabled = true
speed.MaxForce = math.huge
pos.CFrame = pos.Attachment0.WorldCFrame
speed.VectorVelocity = pickedMissile.PrimaryPart.CFrame.LookVector * 500
camera.CameraSubject = pickedMissile.PrimaryPart
task.wait(1)
click = game["Run Service"].RenderStepped:Connect(function()
pos.CFrame = mouse.Hit
--speed.VectorVelocity = mouse.Hit.LookVector * 250
speed.VectorVelocity = pickedMissile.PrimaryPart.CFrame.LookVector * 500
--plr:RequestStreamAroundAsync(pickedMissile.PrimaryPart.Position)
end)
end
end
uis.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.F then
pickMissile()
end
end)
The Scud model has its StreamingMode set to “Persistent,” the actual missile model is also set to that, and resides in a Folder inside the Scud model, and I set the Scud model’s PrimaryPart to be the controlling Player’s character’s PrimaryPart, just like how I do with the battleship, but this issue still occurs. Why?