I need help, the main function of my plugin suddenly stopped working, probably due to some update.
It is a function in the plugin that simply spawns a model in front of the user’s camera. The model has a primarypart.
The problem: the model spawns at a specific location (near the center of the world) for some reason, and even stranger, restarting the studio occasionally resolves it.
This problem started appearing 20 days ago, the plugin with this code has been working for 2 years with no problem.
Spawn function in my plugin:
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local camera = workspace.CurrentCamera
local function spawnfunction()
local model = script.Parent.Other.SPZ --model to spawn
local clone = model:Clone()
local Location = camera.CFrame.Position + (camera.CFrame.LookVector * 5)
clone.Parent = workspace
local x, y, z = workspace.CurrentCamera.CFrame:ToEulerAnglesYXZ()
local lookValue
if y > -0.78539818525314333 and y < 0.7853981852531433 then
lookValue = 0
elseif y > 0.7853981852531433 and y < 2.356194496154785 then
lookValue = 90
elseif y > -2.356194496154786 and y < -0.78539818525314332 then
lookValue = -90
else
lookValue = 180
end
clone:SetPrimaryPartCFrame(CFrame.new(Location)*CFrame.Angles(0,math.rad(lookValue),0))
ChangeHistoryService:SetWaypoint("yo")
end
output shows no error
(I underline this problem for some reason happens sometimes! )
I already know why it is (probably) check out this video 1 and 4 attempts it does the problem and 2, 3 it works, the big difference between those attempts is that the attempts that don’t work have a new loading system! (I have verified this several times outside the video!)
To add to this new update, when I end testing my studio freezes for a few seconds?? The particles are still moving but I cannot move my camera or interact with studio since the recent version
I tried it, unfortunately it has the exact same problem, only the studio thinks the camera is in the center of the map for some reason. I repeat it only happens when it loads using the new loading window.
No it doesn’t work, after the plugin update (which is like reinstalling the plugin) the camera starts working but as soon as I restart the studio/place the problem is back, I meant to imply that the problem is when the place is first loaded
Consider trying different methods for rotating and positioning the model
local location = CFrame.new(cam.CFrame.Position + (cam.CFrame.LookVector * 5), cam.CFrame.Position)
local x, y, z = location:ToOrientation()
clone:PivotTo(CFrame.new(location.Position) * CFrame.Angles(0, math.rad(roundToNearest90(math.deg(y))), 0))
roundToNearest90 function:
local function roundToNearest90(val)
local signValue = math.sign(val)
return math.floor(math.abs((val + (45 * signValue)) / 90)) * (90 * signValue)
end