Hi, I am currently making an infinity gauntlet(simulator) game. I have come across an issue where after I weld the gauntlet to the player when they spawn I can’t position the stones(all seperate object, but the gauntlet is one).
I tried measuring the distance the gauntlet travels when it’s position is changed on spawn and applying that same distance to each stone but they end up getting the same position far away from player.
local gauntlet = script.Parent
local character = gauntlet.Parent
local hand = character:WaitForChild("Left Arm")
local player = game.Players:GetPlayerFromCharacter(character)
for i, v in pairs(workspace:WaitForChild("Gauntlets"):GetChildren()) do
if v.Owner.Value == player.Name then
v:Destroy()
end
end
local oldPosition = gauntlet.Position
gauntlet.CFrame = hand.CFrame * CFrame.new(0, 0.5, 0.1)
gauntlet.Owner.Value = player.Name
gauntlet.Parent = workspace:WaitForChild("Gauntlets")
for i, v in pairs(gauntlet.Stones:GetChildren()) do
local weld = Instance.new("Weld", v)
weld.Part0 = gauntlet
weld.Part1 = v
weld.C1 = gauntlet.CFrame
weld.C0 = v.CFrame
end
local weld = Instance.new("Weld", gauntlet)
weld.Part0 = gauntlet
weld.Part1 = hand
weld.C0 = gauntlet.CFrame
weld.C1 = hand.CFrame
gauntlet.Orientation = Vector3.new(0, 0, 0)
gauntlet.Position -= Vector3.new(0, 0.5, -0.1)
local newPosition = gauntlet.Position
local difference = newPosition - oldPosition
print(difference)
for i, stone in pairs(gauntlet.Stones:GetChildren()) do
print(stone.Position)
stone.Position += difference
print(stone.Position)
end
task.wait(1)
if player:WaitForChild("SaveValues"):WaitForChild("Gear"):WaitForChild("Gauntlet").Value then
for i, v in pairs(player:WaitForChild("SaveValues").Gear:GetChildren()) do
if v.Value then
if gauntlet.Stones:FindFirstChild(v.Name) then
gauntlet.Stones:FindFirstChild(v.Name).Transparency = 0
end
end
end
else
gauntlet.Transparency = 1
end
(I anchored it afterwards to take the picture, because it is welded it moves with my animation)
I need to keep all the stones as seperate objects in order to turn them invisible individually.
Thanks in advance!