Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Orientation of object is wrong only first time I call function. How can I fix that?

Asked by 4 years ago

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

01local items = {}
02 
03    function items.get(player, item)
04        local successful = false
05        local object, pos, ang
06        local animation = Instance.new("Animation")
07 
08        if player.PlayerData.Item.Value == nil then
09            --Get item type
10            if item == "Soda" then
11                object = game:GetService("ServerStorage").Soda
12                animation.AnimationId = "http://www.roblox.com/Asset?ID=5162117084"
13                pos = CFrame.new(0,-1.3,0)
14                ang = Vector3.new(0,0,-90)
15            end
View all 41 lines...

2 answers

Log in to vote
0
Answered by 4 years ago

If you want to get past the problem of it not working first time what you want to do is call the function first, delete the soda, then call the function again and hopefully the soda should be in the correct place.

0
That doesn't fix the problem. You're suggesting to ignore it ThreeTwigs 0 — 4y
0
No offence by the way ThreeTwigs 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

So I think I figured it out. I swapped right arm for torso and adjusted the position and rotation and it worked. Thanks @Gooncreeper for contribution

Answer this question