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

(FIXED) Help with model orientation when summon, please, what i did wrong?

Asked by 6 years ago
Edited 6 years ago

Im not very good using Cframe and Vector3, but i tried, this script "spawn" a model in front of me, and rotate the model to where im looking, but it doesn't work, the script spawn the model, but dont rotate it, what i did wrong?

(Its a LocalScript, in a Tool / The name of the model is test, and i already set the PrimaryPart, that is the "PartePrimaria")

01local skateboardId = 2064283039
02local Tool = script.Parent;
03 
04 
05function insert()
06 
07    --This call will cause a "wait" until the data comes back
08    local root = game:GetService("InsertService"):LoadAsset(skateboardId)
09 
10 
11    local instances = root:GetChildren()
12    if #instances == 0 then
13        root:Remove()
14        return
15    end
View all 61 lines...

Working script :

01local skateboardId = 2064283039
02local Tool = script.Parent;
03local Player = game:GetService('Players').LocalPlayer
04local Character = Player .Character or Player.CharacterAdded:Wait()
05local Torso = Character.Torso --<< this is Torso
06 
07function insert()
08 
09    --This call will cause a "wait" until the data comes back
10    local root = game:GetService("InsertService"):LoadAsset(skateboardId)
11 
12 
13    local instances = root:GetChildren()
14    if #instances == 0 then
15        root:Remove()
View all 63 lines...

1 answer

Log in to vote
1
Answered by
Bertox 159
6 years ago
Edited 6 years ago

You have to set CFrame for lookVector:

1root.Test:SetPrimaryPartCFrame(Torso.CFrame + Torso.CFrame.lookVector*10)

You are using .MouseButton1Down, so it reacts, even when your Tool is not equipped. So you can use .Activated , it only fires when the tool is equipped and you click.

1function activated()
2--
3end
4Tool.Activated:connect(activated)

To get the Torso properly in a local script, you do this:

1local Player = game:GetService('Players').LocalPlayer
2local Character = Player .Character or Player.CharacterAdded:Wait()
3local Torso = Character.Torso --<< this is Torso
0
what is "Model" and "Part"? darkzerobits 92 — 6y
0
Model is your Skateboard and Part is the Torso, You'll have to change that, it is just an example Bertox 159 — 6y
0
If this worked, I'd really love if you gave me a thumbs up and accept my answer Bertox 159 — 6y
0
isn't working :( darkzerobits 92 — 6y
View all comments (3 more)
0
i think the error is how i have set the torso darkzerobits 92 — 6y
0
still not working '-' darkzerobits 92 — 6y
0
now it worked, i used "root.Test:SetPrimaryPartCFrame(Torso.CFrame + Torso.CFrame.lookVector*10)" darkzerobits 92 — 6y
Ad

Answer this question