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

How do I code C-Frame to get player position?

Asked by 5 years ago

I'm making a time stop script for a game I'm working on and need help with C-Framing. I have an Idea as to how to plan it out but not how to do it. How would I code C-Frame position so that it grabs the character's position and adds it to the C-Frame position code?

here the code if it helps:

01if orb then
02    local player = game.Players.LocalPlayer
03    local character = player.Character or player.CharacterAdded:wait()
04    orb.Shape = "Cylinder"
05    orb.Material = "Neon"
06    local weld = Instance.new("WeldConstraint")
07    weld.Parent = workspace
08    weld.Part0 = orb
09    weld.Part1 = character.HumanoidRootPart
10    orb.Position = Vector3.new (106.59,16.5,-111.73) -- Where to add players position, however these coords are preset to a random location since i couldn't figure out how to get Player Position.
0
Tbh, when freezing the player its just best to anchor their parts, also, you're creating stuff from the client, making it only replicate to the client and not the server seeing you used LocalPlayer  mixgingengerina10 223 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hope this helps:

01if orb then
02    local player = game.Players.LocalPlayer
03    local character = player.Character or player.CharacterAdded:wait()
04    orb.Shape = "Cylinder"
05    orb.Material = "Neon"
06    local weld = Instance.new("WeldConstraint")
07    weld.Parent = workspace
08    weld.Part0 = orb
09    weld.Part1 = character.HumanoidRootPart
10    if player.Character:FindFirstChild("Torso") == nil then --checks to see if player is r15
11        orb.Position = Vector3.new (player.Character.LowerTorso.Position.X,player.Character.LowerTorso.Position.Y,player.Character.LowerTorso.Position.Z)
12    else --this is what happens if r6
13        orb.Position = Vector3.new (player.Character.Torso.Position.X,player.Character.Torso.Position.Y,player.Character.Torso.Position.Z)
14    end
15end
Ad
Log in to vote
0
Answered by
Nckripted 580 Moderation Voter
5 years ago

First of all, you would want to do this in a server side script. Else the teleportation will only affect the client. To get the player position, simply use:

1if charactert then
2    orb.CFrame = CFrame.new(character.Position)
3end

Hope this helped! ????

0
I meant to put an emoji, not question marks. Nckripted 580 — 5y
0
Sort of; I see where you are going with the character.Position but when I run the script, I get error 13:24:08.385 - ServerScriptService.BeamSummonEmit:2: attempt to index nil with 'Character'. Is there any way to get around this? I've heard that the character isnt seen serverside. Crimsonknightzone 38 — 5y
Log in to vote
0
Answered by 5 years ago
01if orb then
02    local player = game.Players.LocalPlayer
03    local character = player.Character or player.CharacterAdded:wait()
04    orb.Shape = "Cylinder"
05    orb.Material = "Neon"
06    local weld = Instance.new("WeldConstraint")
07    weld.Parent = workspace
08    weld.Part0 = orb
09    weld.Part1 = character.HumanoidRootPart
10    orb.Position = Vector3.new(player.Character.Torso.Position) -- Get the position of the torso of the local player
11end
0
For some reason, the part spawns at the map Origin... How could i fix this? Crimsonknightzone 38 — 5y

Answer this question