Hi, I am trying to make a forcefield that spins around the player and sometimes moves up and down.
But I have a problem with the forcefield. It wont let the player move normaly and also its spinning the wrong way and I cant anchor it because then the player wont be able to move. If the forcefield is activated (from a item) then it creates a weld between the middlepart and the HumanoidRootPart of the character in the player. Heres a picture how the forcefield looks like:
The middlepart holds all the circles and the shields with welds.
So if I activate the forcefield it wont let me move normaly and it spins completly wrong. I am using a tween and I with that I am trying to spin it around the player.
Here´s the part of the script for the tween:
for i,v in pairs(ForceField:GetChildren()) do
if v:IsA("MeshPart") then
local Tweeninfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true)
local Goal = {Orientation = v.CFrame * Vector3.new(math.rad(360), math.rad(0), math.rad(0))}
local Tween = TweenService:Create(v,Tweeninfo,Goal)
Tween:Play()
end
end
Instead of welding the stuff to the player make it so it keeps moving to the Position of the player.
Maybe that will work?
Something like this:
while wait() do
for i, v in pairs(game.Workspace.forcefield:GetChildren()) do
if v:IsA("MeshPart") then
v.Position = player.Position -- put the player who drank the thing's position here
end
end
end
I’m not sure if this will work as I am kind of new to scripting.
The player can move normaly now but it kinda makes it shaky because of the wait() command and it would fall of the world after some time. Also I cant remove the wait() command because it would crash the game instantly. I think a weld would be better.
You can anchor the meshes now as they are no longer welded. That should take care of the falling down the map and with the “Shakiness” you can make it lerp to the player’s position that would make it seem more natural.
Though if you think welding is better then that’s up to you.
And yes do the thing SnoopDoge is saying.
This will only work as localscript tho, so you would have to make a remote event that would move it to the player position, so everyone could see it moving with player, if it wont work with localscript.
(Replying to my previous reply)
while task.wait() do MainPart.CFrame = CFrame.new(MainPart.Position) * CFrame.fromOrientation(0, math.rad(Main part.Orientation + Vector3.new(0,2,0), 0)} end
The reason for this is because rotating an object 360 degrees brings it back where it started so in the tweens side of things its like it doesnt need to rotate, I recommend you instead make an infinite loop that adds small increments to the rotation.
local RunService = game:GetService('RunService')
RunService.RenderStepped:Connect(function()
MainPart.CFrame = CFrame.new(MainPart.Position) * CFrame.Angles(math.rad(1),0,0)
end)
You can either increase or decrease the increment to make it more smooth
math.rad(MainPart.Orientation + Vector3.new(0,2,0), 0) is underlined with orange I dont know how to fix that to be honest it looks too complicated to me xd