Hi, I am currently making a game similar to Tower of Hell and there are 2 scripts that handle the conveyor parts though when a stage is rotated they conveyor no longer conveys the player in the way it was intended to.
Conveyor Scripts:
function Conveyor(O)
if O.Name ~= "Conveyor" then return end
if not O:IsA("Part") then return end
if not O.Parent or not O:WaitForChild("Texture") or not O:WaitForChild("Speed") then return end
O.Velocity = O.CFrame.lookVector * O.Speed.Value
end
game.Workspace.DescendantAdded:Connect(Conveyor)
for _, v in pairs(game.Workspace:GetDescendants()) do
Conveyor(v)
end
local RunService = game:GetService("RunService")
function Texture(O)
if O.Name ~= "Conveyor" then return end
if not O:IsA("Part") then return end
pcall(function()
local Connection = nil
wait()
Connection = RunService.Heartbeat:Connect(function()
if not O then return end
if not O.Parent or not O:WaitForChild("Texture") or not O:WaitForChild("Speed") then Connection:Disconnect() end
O.Texture.OffsetStudsV = -(game.Workspace.DistributedGameTime * O.Speed.Value) % O.Texture.StudsPerTileV
end)
end)
end
game.Workspace.DescendantAdded:Connect(Texture)
for _, v in pairs(game.Workspace:GetDescendants()) do
Texture(v)
end
You could maybe add a int value inside of the stages when cloning them, their value would be 180 or the other rotation angle depending on the cloning, then if the value is 180, then for example the velocity of the conveyor would be O.Velocity = O.CFrame.lookVector * O.Speed.Value and for the other angle, it would be O.Velocity = O.CFrame.lookVector * -O.Speed.Value
The int values helps determine the rotation of the stage, so if the rotation set by the stage script for the stage is 180, then you set the Int Value you pre-made into the stage to 180, samething for example the angle -180 or 0.
Well first of all, you would insert a int value inside of all of your stages, then in the stage script, you would change the int value to the rotation of the stage you’re cloning.
It’s okay, I understand visuals more than text. Though I have one more problem, how exactly could I get the conveyor script to find the int values in each stage?
local Stage = -- Find the stage using O.Parent or O.Parent.Parent ...
local RotationV = Stage:FindFirstChild("RotationValue")
if RotationV.Value == 180 then
O.Velocity = O.CFrame.lookVector * O.Speed.Value
else
O.Velocity = O.CFrame.lookVector * -O.Speed.Value
end
This isn’t nessasarily related, but you seem to be using a lot of values. Have you tried attributes?
Learn how to use attributes at Instance Attributes.
Thanks the conveyors work properly now. This isn’t necessary but is there a way to make it detect the stage if the conveyors were to be put in extra models?
I wouldn’t say harder to understand. I think they’re much neater. They’re part of the Instance themselves, so you also don’t have to wait for them to replicate. You can change them right in the Properties tab of the Instance too.
Make extra checks to see if the parent that defines the stage is different (example):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
if ReplicatedStorage:FindFirstChild(O.Parent.Name) then
-- -- Code
elseif ReplicatedStorage:FindFirstChild(O.Parent.Parent.Name) then
-- Code
end
I understand what you’re saying, but if I were that person, I wouldn’t take extra time to make use of the feature, because of how little difference it makes.