This is code that spaws Soda and attaches it to player. The problem is that first time the function is called it spaws Soda is wrong orientation. Second times it's called it's as intended.
Images for reference: image1, image2
local items = {}
function items.get(player, item)
local successful = false
local object, pos, ang
local animation = Instance.new("Animation")
if player.PlayerData.Item.Value == nil then
--Get item type
if item == "Soda" then
object = game:GetService("ServerStorage").Soda
animation.AnimationId = "http://www.roblox.com/Asset?ID=5162117084"
pos = CFrame.new(0,-1.3,0)
ang = Vector3.new(0,0,-90)
end
local arm = player.Character["Right Arm"] --Spawning and position
local clone = object:Clone()
clone.Anchored = false
clone.Parent = arm
player.PlayerData.Item.Value = clone
clone.CFrame = arm.CFrame:ToWorldSpace(pos)
clone.Orientation = ang
local weld = Instance.new("WeldConstraint") --Weld parts
weld.Parent = clone
weld.Part0 = arm
weld.Part1 = clone
--Animation
local animationTrack = player.Character.Humanoid:LoadAnimation(animation)
animationTrack:Play()
successful = true
end
return successful
end
return items

2 comments
That doesn't fix the problem. You're suggesting to ignore it
No offence by the way