Cframe Works In Studio, But frozen in game

So In my Game there are cylinders that crash into England.
I got the script to work in the test , but not when I load it in game or Play Here or Play. it will work but when falling it will just stay stuck above in the air. Now the script Dose continue to run, as the lid of the cylinder falls off onto the map. I check the Output and Dev Console and nothing is showing errors. My game I am Making is based off the H.G Wells The War Of The Worlds.

Cylinder Code In replicated Storage:

local Lid = script.Parent["Lid"]
local trail = script.Parent["Trail"]
local smoke = script.Parent["Smoke"]
local light = script.Parent["SurfaceLight"]
local screw = Lid.Screw
local heat = script.Parent["Heat"]
local crater = game.ReplicatedStorage.Crater

print("Shooting")
for i=1,75 do
	cylinder.CFrame=cylinder.CFrame+Vector3.new(100,-20,0)
	wait(0)
end

cylinder.Anchored = true
local newCrater = crater:Clone()
newCrater.CFrame = cylinder.CFrame
newCrater.Parent = workspace
cylinder.CanCollide = true
heat.Enabled = true
light.Enabled = false
trail.Enabled = false
smoke.Enabled = false
print("landed")
wait(20)
heat.Enabled = false
local weld = cylinder.WeldConstraint
weld:Destroy()
screw.Enabled = true
Lid.Anchored = true
Lid.CanCollide = false
wait(2)
screw.Enabled = false
local rs: (RunService) = game:GetService("RunService")
local i = 0
local rs: (RunService) = game:GetService("RunService")
local i = 0
while rs.Heartbeat:Wait() and i <= 600 do --100 is the amount of times you want the code below to run
	i += 1
	Lid.CFrame = Lid.CFrame * CFrame.Angles( 0, math.rad(1), 0 ) * CFrame.new(0,0.03,0) 
end
Lid.Anchored = false
Lid.CanCollide = true
print("openLid") 

Here is what It looks like in the studio and when it dose work.


Here is it in game.

2 Likes

When is this code running? There is a chance that the code finishes execution by the time your player’s characters spawns in to see.

1 Like

It runs on day 1 and day 0 is the starting day. When the code runs it like teleports above were it would have “landed”

So It was more of a Lag Problem. Also had to change it from replicated storage to ServerStorage

Ok so it works now in studio with play and play here. But now does not work in game. It’s still frozen in air. Though it still runs threw it’s script.

You could try printing each time you do something, and see if something isn’t running accordingly.

1 Like

I have and it prints “shooting” though it never moves and yet, it continues to run the script.

1 Like

The only thing I could recommend now is lerping the part.
Link to lerping “tutorial” if you will

1 Like

Wait could it not work because of network ownership? The cylinders is un anchored

You could try moving the script into else where and testing if it works like starter character for instance
That may help you. I found problems like this and its often solved by moving the script places.
Filtering enabled could also be a issue.
Also where in fact is the actual parts?

1 Like

The Parts have been put in serverStorage. Now I have it set up to were like in the book 1 cylinder at midnight. image

It would be better to put them in replicated. And put the script into server storage. But idk if that would break it but its worth a try well like try changing them around abit to see if they work in different area’s.
if you don’t really wanna change the scripts just put them in the different places in studio and see if it works in game!

1 Like

I think this code needs a complete rewrite.

local cylinder = script.Parent
local Lid = script.Parent["Lid"]
local trail = script.Parent["Trail"]
local smoke = script.Parent["Smoke"]
local light = script.Parent["SurfaceLight"]
local screw = Lid.Screw
local heat = script.Parent["Heat"]
local crater = game.ReplicatedStorage.Crater

print("Shooting")
for i=1,75 do
	cylinder.CFrame=cylinder.CFrame+Vector3.new(100,-20,0)
	wait(0)
end

cylinder.Anchored = true
local newCrater = crater:Clone()
newCrater.CFrame = cylinder.CFrame
newCrater.Parent = workspace
cylinder.CanCollide = true
heat.Enabled = true
light.Enabled = false
trail.Enabled = false
smoke.Enabled = false
print("landed")
wait(40)
heat.Enabled = false
local weld = cylinder.WeldConstraint
screw.Enabled = true
Lid.Anchored = true
Lid.CanCollide = false
wait(2)
screw.Enabled = false
local rs: (RunService) = game:GetService("RunService")
local i = 0
while rs.Heartbeat:Wait() and i <= 500 do --100 is the amount of times you want the code below to run
	i += 1
	Lid.CFrame = Lid.CFrame * CFrame.Angles( 0, math.rad(1), 0 ) * CFrame.new(0,0.03,0) 
end
weld:Destroy()
Lid.Anchored = false
Lid.CanCollide = true
print("openLid")
1 Like

The problem is it could be non server sided also. So I would copy that code and put it away for later then edit that to work for a normal script or even use remote events for certain things or just completely rewrite the code in its own write without making it a normal script.
I hope you make the script work in game properly!
I will try to help you out as much as I can for this topic if its really a problem.

1 Like

The print shooting part doesn’t actually tell you if the script is running properly. Try placing print shooting in all of the script executions and out and count how many you put and how many are being activated before you start changing the code.
Test it in game where it doesn’t work and some how use the developer console or something like that to see how many are actually being set off.
So it tells you how much of the script is actually running properly!

The Scripts works, Well it Spawns in workspace but it stuck in the air. Though it will run though its code still as it prints the rest of the code and the lid falls off.

1 Like

If the lid falls off it might have something to do with anchored part of the script.
Try rewritting that!

oops, I meant that is suposed to happen. image I think it is filter enabled as when I do test it works as should and when I do current client it works. Wait So It did work in client when I had it ServerStorage. But in replicated storage it doesn’t work.

Oh sorry, Well I hope you find a answer to your problem but I think you should test two players on the game in game and see how it works.

1 Like

This should prove useful for the problem read up on it:

I hope this was useful (Skip to the solution) after reading the problem.

1 Like