-
What do you want to achieve? am trying to make the part follow the players humanoid rootpart and trying to make it look smoothly by lerping it, here is the script i’ve made
local tweenservice = game:GetService ("TweenService")
local contextactionservice = game:GetService("ContextActionService")
local char = script.Parent
local humanoidrootpart = char:WaitForChild("HumanoidRootPart")
local coolgui = workspace.C00LGUI
contextactionservice:BindAction("show_part", function(_, state, obj)
if state ~= Enum.UserInputState.Begin then return end
coolgui.Orientation = Vector3.new(-30,0,0)
tweenservice
:Create(coolgui, TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.InOut), {["Size"] = coolgui.Size.X == 3 and Vector3.new() or Vector3.new(3, 1.75, 0.25)})
:Play()
for i=0, 1, 0.01 do
coolgui.Position = humanoidrootpart.CFrame:Lerp(humanoidrootpart * Vector3.new(0,0.6,-2), i)
end
end, false, Enum.KeyCode.E)
and am also trying to make the y rotation of the part follows the players y rotation if you can also help me with that it would be super helpful -Thank you in advance!
1 Like
why not use alignposition and alignorientation to move the part to follow the player its more realistic than TweenService.
3 Likes
You can manipulate the attachments of the alignposition and align orientation properties with TweenService for a initial effect of part appearing
1 Like
right i didn’t think of that, i’ll update you if it works or not thanks for the idea!
ok good luck using mover constraints
yeah uhm that didn’t go as planned
it’s like stuck right on my head i wanted to make an offset by doing a vector and moving it a bit away but for some reason it wont work
and also i tried to make a clone so each player can get his own part following him but it was like in the middle of the 2 players it was attached to both of them anyways here is the code i made for it
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local newpart = workspace.follow:Clone()
newpart.Parent = workspace
newpart = workspace:WaitForChild("follow"):WaitForChild("Attachment")
local humanoid = char:WaitForChild("Head"):WaitForChild("HatAttachment")
local align = Instance.new("AlignPosition")
align.Parent = char
align.Attachment1 = humanoid
align.Attachment0 = newpart
end)
Thanks!
Create a default attachment for the players character parented to their humanoiddrootpart or head then you can offset with a script or manually
1 Like
Try to parent the part to the players character
1 Like
And dont use waitforchild for the part named follow as it will find a part in the workspace named follow and use it as your specificied part when you wanted the players follow part
1 Like
Instead write:
newpart=newpart:WaitForChild(“Attachment”)
1 Like
that’s actually pretty genius god dang why didn’t i think of that
its the power of logic and basic reading of the code
hello there, sorry dont wanna bother ya but got good news and bad news most of the problems that i had are fixed there is just 1 more teeny tinny problem i’ve still made it that it clones a newpart for each player when they joined the it was successful, but 1 problem they both share the same part
but the part was just following 1 player the other cloned part wasn’t working only one part was working this might seem a bit confusing to read just message me if you want more details, thank you for your time again!
k could you show the new script you wrote.Its easier visually then worded.
Nah actually dont do what i wrote above i figured it out visually in my mind.The logic behind that 1 problem is that you need to destroy that old cloned part because say you leave the game or your character is destroyed that part was linked to that character but not your new character that you currently have spawned or is spawning.In theory its a whole new object.
So set up a char.Humanoid.Died Event to achieve the result
huh didn’t quite understand that sorry also it’s alr let me just send u the script i made i might have made a small mistake, anyways here ya go
local replicated = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local part = replicated:WaitForChild("C00LGUI")
local attachment = Instance.new("Attachment")
local newpart = part:Clone()
newpart.Parent = workspace
attachment.Parent = newpart
newpart.Orientation = Vector3.new(-30,0,0)
local part2 = char:WaitForChild("Weld")
local part2attach = part2:WaitForChild("Attachment")
local partnewattach = newpart:WaitForChild("Attachment")
local alignpos = Instance.new("AlignPosition")
alignpos.Attachment1 = part2attach
alignpos.Attachment0 = partnewattach
alignpos.Parent = char:WaitForChild("Head")
alignpos.Responsiveness = 1
end)
appreciate the help dude you are the best
This code is quite not efficient for starters and not flexible but ill fix some parts
Try this:
local replicated = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local head=char:WaitForChild("Head")
local part = replicated:WaitForChild("C00LGUI")
local attachment = Instance.new("Attachment")
local newpart = part:Clone()
newpart.Parent = workspace
attachment.Parent = newpart
newpart.Orientation = Vector3.new(-30,0,0)
local attachment1 = Instance.new("Attachment")
attachment1.Parent = head
local alignpos = Instance.new("AlignPosition")
alignpos.Attachment1 = attachment1
alignpos.Attachment0 = attachment
alignpos.Parent = head
alignpos.Responsiveness = 1
char.Humanoid.Died:Connect(function()
newpart:Destroy()
end
end)
1 Like
if you want the part to be destroyed when the player’s character is about to be removed from the workspace use the CharacterRemoving Event from Players Service.And for more smoothness try using networkownership on the part set to the player.
1 Like
OH IT WORKED! thank you SO freaking much i appreciate your patience your help and your time dude you are the best