Slac3r
(Slac3r)
October 9, 2022, 11:15pm
#1
So I have this Ice Trident that goes to the position of the players mouse, but I want it to be facing this direction and is facing the direction it is going:
I have tried orientations and that didnt seem to work, and I dont have any other idea how to implement this. Thanks for the help!
Video of whats happening:
robloxapp-20221009-1610299.wmv (872.6 KB)
Script:
game.ReplicatedStorage.Remotes.IceShard.OnServerEvent:Connect(function(player, mousep)
local tweenservice = game:GetService('TweenService')
local clone = game.ReplicatedStorage.Fruits.Ice.Shard:Clone()
local char = player.Character
clone.CFrame = char.LowerTorso.CFrame
clone.Position = Vector3.new(clone.Position.X, clone.Position.Y, clone.Position.Z)
clone.Parent = char
local tweeninfo = TweenInfo.new(
0.6,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = tweenservice:Create(clone, tweeninfo, {Position = mousep.Position})
tween:Play()
player.stats.Stamina.Value = player.stats.Stamina.Value - 10
tween.Completed:Wait()
local hitboxclone = game.ReplicatedStorage.HitBox:Clone()
hitboxclone.Parent = clone
hitboxclone.Position = clone.Position
local explosion = Instance.new('Explosion')
explosion.Parent = clone
explosion.BlastRadius = '10'
local smoke = game.ReplicatedStorage.Ice:Clone()
smoke.Parent = clone
clone:Destroy()
print('destroyed')
end)
Dont worry, I’m planning to change it to BodyVelocities in the future!
Kaid3n22
(Kaiden)
October 9, 2022, 11:20pm
#2
add this before playing the tween:
clone.CFrame = CFrame.lookAt(clone.Position, mousep.Position)
Slac3r
(Slac3r)
October 9, 2022, 11:29pm
#3
I just added it, there was no difference
Kaid3n22
(Kaiden)
October 9, 2022, 11:32pm
#4
I believe this has to do with the way the trident is oriented. Could you provide the trident model so I could try and fix this in my studio? It’s a bit hard to try and mess with weird orientations without it being hands-on.
Slac3r
(Slac3r)
October 10, 2022, 2:32am
#5
Alright, also is these a way you can make 2 meshes into 1 part or they attach together. Ive tried with weld constraints and only the bottom part of the trident part cloned. Sorry for the late response.
Model: Ice Trident - Roblox
Ahdlibya
(absolute_zero)
October 10, 2022, 2:57am
#6
game.ReplicatedStorage.Remotes.IceShard.OnServerEvent:Connect(function(player, mousep)
local tweenservice = game:GetService('TweenService')
local clone = game.ReplicatedStorage.Fruits.Ice.Shard:Clone()
local char = player.Character
clone.CFrame = char.LowerTorso.CFrame
-- add this
clone.CFrame = clone.CFrame*CFrame.Angles(0 , math.rad(-90) , math.rad(90))
clone.Parent = char
local tweeninfo = TweenInfo.new(
0.6,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = tweenservice:Create(clone, tweeninfo, {Position = mousep.Position})
tween:Play()
player.stats.Stamina.Value = player.stats.Stamina.Value - 10
tween.Completed:Wait()
local hitboxclone = game.ReplicatedStorage.HitBox:Clone()
hitboxclone.Parent = clone
hitboxclone.Position = clone.Position
local explosion = Instance.new('Explosion')
explosion.Parent = clone
explosion.BlastRadius = '10'
local smoke = game.ReplicatedStorage.Ice:Clone()
smoke.Parent = clone
clone:Destroy()
print('destroyed')
end)
Try to use this it my be work for you
i just fix some math issue but still my by not 100% sure if it work or not
Slac3r
(Slac3r)
October 10, 2022, 3:19am
#7
Yes, it is very close, it is the trident is tilted a little bit.
Video:
robloxapp-20221009-2018509.wmv (755.4 KB)
1 Like
Kaid3n22
(Kaiden)
October 10, 2022, 3:22am
#8
Here’s the fix I found:
clone.CFrame = CFrame.lookAt(clone.Position, mousep.Position)*CFrame.Angles(math.rad(-90),0,0)
Sorry for the late response, I wasn’t online at the time
Slac3r
(Slac3r)
October 10, 2022, 3:25am
#9
Thank you so much! It works perfectly, thanks for your help!
Slac3r
(Slac3r)
October 10, 2022, 3:26am
#10
also is these a way you can make 2 meshes into 1 part or they attach together. I’ve tried with weld constraints and only the bottom part of the trident part cloned.
As you can see, the spiky part is not there:
The spikey part falls off once it spawns, is there a way to fix this so it looks like this?
Kaid3n22
(Kaiden)
October 10, 2022, 3:35am
#11
Hold on, I will try and find a solution to this.
Kaid3n22
(Kaiden)
October 10, 2022, 3:40am
#12
Alright, I kept them into the model and had both of them anchored. (They were not under each other) I then used this script:
workspace.Trident.PrimaryPart.CFrame = CFrame.lookAt(workspace.Trident.PrimaryPart.Position, workspace.Parta.Position)*CFrame.Angles(80,0,0)
local tween1 = game:GetService("TweenService"):Create(workspace.Trident["Meshes/trident_Plane (1)"], TweenInfo.new(1), {Position = workspace.Parta.Position})
local tween2 = game:GetService("TweenService"):Create(workspace.Trident["Meshes/trident_Cone (1)"], TweenInfo.new(1), {
Position = workspace.Parta.Position * ((workspace.Trident["Meshes/trident_Plane (1)"].Position - workspace.Parta.Position).Unit * (workspace.Trident["Meshes/trident_Plane (1)"].Position - workspace.Trident["Meshes/trident_Cone (1)"].Position).Magnitude)
})
tween1:Play()
tween2:Play()
The PrimaryPart of the model was set to the trident_Plane. Hopefully you can convert this script to work for you
Edit: not sure why, but I had to change the angle at which I was using CFrame.Angles() to fix it with the model.
Slac3r
(Slac3r)
October 10, 2022, 4:47am
#13
Thank you! It worked again, I also changed it to BodyVelocity to make it the same speed! Thanks for the help!