Player-controlled missile freezes/pauses randomly

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?

2 Likes

Even stranger, sometimes I will almost get to the other side of the map without any issues, and then it will freeze.

I believe the issue is related to the LinearVelocity somehow, as the AlignOrientation continues to update during the freeze, but LinearVelocity stays the same

1 Like

You have fixed it before, Parent the missile to the player’s Character.

1 Like

It already is parented to the player’s character, as well as the PrimaryPart of the Character being set to the PrimaryPart of the missile.

2 Likes

Then try playing with the missile’s ModelStreamingMode until it fixes the problem.

Been doing that for hours now. No luck.

1 Like

Maybe try to set the network owner to the server, so the server continues to simulate the model:

missile:SetNetworkOwner(nil)
1 Like

Doing this would mean the missile would not be controllable anymore by the player.

1 Like

Maybe try and see if it does affect the controlling.

1 Like

You cannot control vehicles like missiles with LocalScripts without setting the NetworkOwner to the player. The missile will not move then.

1 Like

I fixed it.

The solution was very weird.

It had something to do with the origin points of the missile.

For my battleship, when you buy it, you only buy the spawner for it - each Battleship requires the player to spawn it in from ServerStorage, and there are no issues.

For the Scud, when you bought it, the launcher model was right there. But it resulted in this weird glitch.
The solution was to make it so the model bought in the tycoon, and the player had to use it to spawn the actual Scud in from ServerStorage. The issue was fixed with this.

It’s kind of hard to explain this over text, since it was such a weird solution, but this just confirms how bizarre StreamingEnabled’s behavior can be,

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.