So I have an alarm system that goes on when I fire it via a module. The problem is that the hinge constraint gets stuck after 5 seconds and won’t move again. I have tried numerous fixes and nothing has worked. Roblox also doesn’t report errors for my script as well.
My developers were saying this might be a Roblox bug, but I sure hope it isn’t.
Please help me out.
When the player gets close to an unanchored part, they gain NetworkOwnership automatically. That’s why it’s not recommended to use Hinges for systems that you want to be purely serversided, and instead to use TweenService on each client, so they don’t affect eachother.
That’s odd. I have used Hinge Constraints on all my alarms and they worked completely fine. Heck, the same alarms I showed worked before I had this issue. I even made one more recently with hinge constraints and they worked fine.
I’ve even seen other really good builders using this over client tween.
Any unanchored part can be controlled by exploiters though, so I would recommend switching to TweenService. You can test this by yourself by going to studio settings, then physics, and then turning on Are Owners Shown, and Are Regions Shown. When that unanchored part is in your region, try moving it, and you will see that it will replicate to the server.
Need more information on it? Here is a good explanation by @colbert2677:
You are allowing your game to be exploited really easily if you use constraints (that are not properly anchored).
Not sure why they would, probably because it’s easier than using TweenService?
You could always test it first, in my experience, TweenService has had no performance issues when done on the client. It always matters what you value most though.
I’ll go test right now and tween 2500 parts and see if there is any lag. I’ll keep you posted on the results.
Scratch all that, I would have to recode the whole module script which is a nightmare. I mainly just want to find the cause for why the alarms are suddenly stopping.
They also stop in run mode as well.
Tbh, I don’t have any other hinge constraints besides the alarms.
Have you tried adding a WeldConstraint so it doesn’t fall, then removing and adding the HingeConstraint, and then removing the WeldConstraint?
Unrelated but here’s how tweening 2500 parts went:
(sorry for the low quality, I cropped my studio screen to only include the viewport, and sorry for the download link, I sent a streamable link but for some reason Roblox is making it a download)
local Folder = Instance.new("Folder")
Folder.Name = "Parts"
Folder.Parent = workspace
for i = 1, 50 do
for j = 1, 50 do
local newPart = Instance.new("Part")
newPart.Anchored = true
newPart.CanCollide = false
newPart.CanTouch = false
newPart.CanQuery = false
newPart.Position = Vector3.new(i * 5, 0, j * 5)
newPart.Parent = Folder
end
end
LocalScript in StarterPlayerScripts:
--//Services
local TweenService = game:GetService("TweenService")
--//Variables
local Parts = workspace:WaitForChild("Parts")
--//Functions
local function InitializePart(part)
while true do
local rotationTween1 = TweenService:Create(part, TweenInfo.new(3, Enum.EasingStyle.Linear), {Orientation = Vector3.yAxis * -90})
rotationTween1:Play()
rotationTween1.Completed:Wait()
local rotationTween2 = TweenService:Create(part, TweenInfo.new(3, Enum.EasingStyle.Linear), {Orientation = Vector3.yAxis * -180})
rotationTween2:Play()
rotationTween2.Completed:Wait()
end
end
Parts.ChildAdded:Connect(InitializePart)
for i, part in Parts:GetChildren() do
task.spawn(InitializePart, part)
end
local module = {}
function module.AlarmStart(color:Color3, sound)
for i,v in pairs(game.Workspace.Systems.Announcers:GetChildren()) do
if v:IsA("Model") then
for i,v in pairs(v.Light:GetChildren()) do
if v:IsA("SpotLight") then
v.Enabled = true
v.Color = color
end
end
v.Light.Material = Enum.Material.Neon
v.Light.Color = color
v.Light2.Color = color
v.SoundMain.Alarm.SoundId = sound
v.LightBase.HingeConstraint.AngularVelocity = 2.5
v.SoundMain.Alarm:Play()
end
end
end
function module.StopAlarms()
for i,v in pairs(game.Workspace.Systems.Announcers:GetChildren()) do
if v:IsA("Model") then
for i,v in pairs(v.Light:GetChildren()) do
if v:IsA("SpotLight") then
v.Enabled = false
end
end
v.Light.Material = Enum.Material.SmoothPlastic
v.LightBase.HingeConstraint.AngularVelocity = 0
v.SoundMain.Alarm:Stop()
end
end
end
return module