Slac3r
(Slac3r)
September 18, 2022, 8:50pm
#1
I have these 2 parts that tween into teach other but they always spawn in one direction. How could I change this so that the part spawns in front of the direction the player is looking?
game.ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local tweenservice = game:GetService('TweenService')
local clone = game.ReplicatedStorage.IceLeftWall:Clone()
local char = plr.Character
clone.CFrame = char.LowerTorso.CFrame*CFrame.new(0,0,5)
clone.Position = Vector3.new(char.HumanoidRootPart.Position.X -80, char.HumanoidRootPart.Position.Y , char.HumanoidRootPart.Position.Z - 60)
clone.Rotation = Vector3.new(0, 270, 0)
clone.Parent = char
local clone2 = game.ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.LowerTorso.CFrame*CFrame.new(0,0,5)
clone2.Position = Vector3.new(char.HumanoidRootPart.Position.X +80, char.HumanoidRootPart.Position.Y , char.HumanoidRootPart.Position.Z - 60 )
clone2.Rotation = Vector3.new(0, 90, 0)
clone2.Parent = char
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = tweenservice:Create(clone, tweeninfo, {Position = Vector3.new(clone.Position.X + 80, clone.Position.Y, clone.Position.Z)})
local tween2 = tweenservice:Create(clone2, tweeninfo, {Position = Vector3.new(clone2.Position.X - 80, clone2.Position.Y, clone2.Position.Z)})
tween:Play()
tween2:Play()
tween.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Katrist
(Katrist)
September 18, 2022, 8:56pm
#2
You can use the LookVector to achieve this.
New code:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 5
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 5
clone2.Parent = char
local tween = TweenService:Create(clone, tweeninfo, {Position = Vector3.new(clone.Position.X + 80, clone.Position.Y, clone.Position.Z)})
tween:Play()
local tween2 = TweenService:Create(clone2, tweeninfo, {Position = Vector3.new(clone2.Position.X - 80, clone2.Position.Y, clone2.Position.Z)})
tween2:Play()
tween2.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Slac3r
(Slac3r)
September 18, 2022, 10:12pm
#3
Sorry for the late response, but this happens, it tweens in the other direction and is sideways. I will attach a video
robloxapp-20220918-1511109.wmv (450.7 KB)
Katrist
(Katrist)
September 18, 2022, 10:22pm
#4
Try this:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = (char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 20) * CFrame.fromEulerAngles(0, math.rad(90), 0)
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = (char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 20) * CFrame.fromEulerAngles(0, math.rad(90), 0)
clone2.Parent = char
local tween = TweenService:Create(clone, tweeninfo, {Position = Vector3.new(clone.Position.X + 80, clone.Position.Y, clone.Position.Z)})
tween:Play()
local tween2 = TweenService:Create(clone2, tweeninfo, {Position = Vector3.new(clone2.Position.X - 80, clone2.Position.Y, clone2.Position.Z)})
tween2:Play()
tween2.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Slac3r
(Slac3r)
September 18, 2022, 11:08pm
#6
Its also bugged for all directions
robloxapp-20220918-1522520.wmv
OwlCodes
(Owl)
September 19, 2022, 2:29am
#7
I know the problem it is because in the code it says:
clone2.Position.X - 80
Meaning it’ll only tween out of the X axis!
I’ll attempt to rewrite it and see if this works!
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 5
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 5
clone2.Parent = char
local tween = TweenService:Create(clone2, tweeninfo, {CFrame = CFrame.new(char.HumanoidRootPart.CFrame.X + 80, char.HumanoidRootPart.CFrame.Y, char.HumanoidRootPart.CFrame.Z)})
tween:Play()
local tween2 = TweenService:Create(clone2, tweeninfo, {CFrame = CFrame.new(char.HumanoidRootPart.CFrame.X - 80, char.HumanoidRootPart.CFrame.Y, char.HumanoidRootPart.CFrame.Z)})
tween2:Play()
tween2.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
I hope this helps I am not sure if it works. Let me know!
Slac3r
(Slac3r)
September 19, 2022, 4:38am
#8
The same issue is there
If you didnt know this is what I want (I want this to spawn in the direction the player is looking)
robloxapp-20220918-2138284.wmv (591.3 KB)
And this is whats happening
robloxapp-20220918-2136507.wmv (1.7 MB)
OwlCodes
(Owl)
September 19, 2022, 5:42am
#9
So you want them in the direction the player is facing and shoot out that way too?
Slac3r
(Slac3r)
September 19, 2022, 9:48pm
#10
I want them to crash into each other in the direction their facing (first video from the post above), again sorry for the late response.
Katrist
(Katrist)
September 19, 2022, 10:53pm
#11
Try this:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 20 + -char.CFrame.RightVector * 40
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.LowerTorso.CFrame + char.LowerTorso.CFrame.LookVector * 20 + char.CFrame.RightVector * 40
clone2.Parent = char
local leftWallTween = TweenService:Create(clone, tweeninfo, {CFrame = clone.CFrame + clone.CFrame.LookVector * 30})
leftWallTween:Play()
local rightWallTween = TweenService:Create(clone2, tweeninfo, {CFrame = clone.CFrame + clone.CFrame.LookVector * 30})
rightWallTween:Play()
rightWallTween.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Slac3r
(Slac3r)
September 19, 2022, 11:07pm
#14
I changed char.CFrame
into char.PrimaryPart.CFrame
and its like this now, also the error is gone
robloxapp-20220919-1604236.wmv (1.9 MB)
I want it to be like this (link below) but for the direction the player is looking at
Slac3r
(Slac3r)
September 19, 2022, 11:08pm
#15
It also goes a little bit into the ground, I just want it to stay on ground level
Katrist
(Katrist)
September 19, 2022, 11:14pm
#16
Okay, I tried rotating the walls to the right way, try this:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + -char.PrimaryPart.CFrame.RightVector * 40
clone.CFrame *= CFrame.fromEulerAngles(0, math.rad(-90), 0)
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + char.PrimaryPart.CFrame.RightVector * 40
clone2.CFrame *= CFrame.fromEulerAngles(0, math.rad(90), 0)
clone2.Parent = char
local leftWallTween = TweenService:Create(clone, tweeninfo, {CFrame = clone.CFrame + clone.CFrame.LookVector * 30})
leftWallTween:Play()
local rightWallTween = TweenService:Create(clone2, tweeninfo, {CFrame = clone.CFrame + clone.CFrame.LookVector * 30})
rightWallTween:Play()
rightWallTween.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Slac3r
(Slac3r)
September 19, 2022, 11:23pm
#17
Wow, your really close, but one of them is making a 180 degree turn, I will attach a video on whats happening
robloxapp-20220919-1622079.wmv (810.1 KB)
Katrist
(Katrist)
September 19, 2022, 11:28pm
#18
Okay this should work perfectly then:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + -char.PrimaryPart.CFrame.RightVector * 40
clone.CFrame *= CFrame.fromEulerAngles(0, math.rad(-90), 0)
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + char.PrimaryPart.CFrame.RightVector * 40
clone2.CFrame *= CFrame.fromEulerAngles(0, math.rad(90), 0)
clone2.Parent = char
local leftWallTween = TweenService:Create(clone, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * 30})
leftWallTween:Play()
local rightWallTween = TweenService:Create(clone2, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * 30})
rightWallTween:Play()
rightWallTween.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
1 Like
Slac3r
(Slac3r)
September 19, 2022, 11:30pm
#19
And your correct! But can you make it so that it spawns a bit more forward? It spawns inside of the player and kills them
Katrist
(Katrist)
September 19, 2022, 11:31pm
#20
Okay, here, you can edit the variable depending on how far forward you want.
New code:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--//Controls
local forwardDistance = 50
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then
return
end
local clone = ReplicatedStorage.IceLeftWall:Clone()
clone.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + -char.PrimaryPart.CFrame.RightVector * 40
clone.CFrame *= CFrame.fromEulerAngles(0, math.rad(-90), 0)
clone.Parent = char
local clone2 = ReplicatedStorage.IceRightWall:Clone()
clone2.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * 20 + char.PrimaryPart.CFrame.RightVector * 40
clone2.CFrame *= CFrame.fromEulerAngles(0, math.rad(90), 0)
clone2.Parent = char
local leftWallTween = TweenService:Create(clone, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * forwardDistance})
leftWallTween:Play()
local rightWallTween = TweenService:Create(clone2, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * forwardDistance})
rightWallTween:Play()
rightWallTween.Completed:Wait()
clone:Destroy()
clone2:Destroy()
end)
Katrist
(Katrist)
September 19, 2022, 11:35pm
#21
Oh wait, I edited the script wrong, I’ll fix it real quick.
Slac3r
(Slac3r)
September 19, 2022, 11:35pm
#22
Yeah, I changed the number to 100 and it glitched out