I made this minigame where the lava moves back and forth and you have to jump over it, but it is glitched and doesn’t pose enough of a challenge because the lava just teleports above you when it is about to collide. Do you guys have any idea of how to fix this because what I did (See code) does not work.
Roblox footage pls help - YouTube footage of the thing not working
Use SetPrimaryPartCFrame so that you can use CFrames. That way it won’t try to position itself on top of things it hits.
Ok, I’ll try, not sure if it will work because it is in a model but idk.
It didn’t work, do you think I should move the script into the part?
do CFrame.new(pos.x,pos.y,pos.z)
instead of SetPrimaryPartCFrame(pos.x,pos.y,pos.z)
Since you are just setting it to 3 positions and not an CFrame which is making it not work
should go to this:
SetPrimaryPartCFrame(CFrame.new(pos.x,pos.y,pos.z))
:SetPrimaryPartCFrame()
is deprecated, use :PivotTo()
instead
Also, this gets a CFrame value, so you will need to use CFrame.new()
to give the Vector3 as a CoordinateFrame.
Why don’t you use TweenService? It allows you to set interpolation and has a repeat and reverse option that doesn’t require looping.
Idk how and I don’t think it would be able to detect the touch while moving, it needs to detect the touch to kill the player. How do I use TweenService?
Well then basically do this:
script.Parent.PrimaryPart.CFrame + CFrame.new(x,y,z)
Here’s what you could do:
local TS = game:GetService("TweenService")
local Object = script.Parent
local TInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true)
-- 0.5 is time it takes, both enums change the interpolation, -1 means it repeats infinitely, and true means it reverse.
TS:Create(Object, TInfo, {Position = Object.Position + Vector3.new(0,5,0)}):Play() -- Change 5 in the Vector3 to whatever
-- Creates Tween with TweenService and calls Play on its returned instance.
Object.Touched:Connect(function(instance)
if instance.Parent:FindFirstChildOfClass("Humanoid") then
if instance.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then -- Checks if health is 0
instance.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(100) -- How much health is removed?
end
end
end)
Also forgot to mention .Touch:Connect(function() connects the following to the part returned
Your fix didn’t work, it doesn’t let it move at all now. I’m confused on why it does this but now it wants the cframe.new to be vector3.new and when I did that it was still sideways.
Oh you could try using * CFrame.new() then
What do you mean by this? I did I think
I think I figured it out now, I’ll tell you how it goes when I get back to my desk.