Goal
I’m creating a light admin command. How it’s supposed to work is; when a player says /light PLAYERNAME 255,0,0
, the light model will go infront of the character as shown.
The light model is added, and edited on the server and is not created when the Player Joins, or the character is added. The light model is only created when an admin runs the light
command.
Issue
The part’s position changes with the players turn. Here’s examples with the character facing opposite directions.
|
PivotTo Issue
I’ve tried using PivotTo already three times, it has not worked once for me.
The brick on the right that has no neon on it, is supposed to be the light. With this, when I use PivotTo, it teleports my character.
Here’s a video to show the issues with PivotTo.
Creating the Issue
How you create the problem is by doing the following;
- Spawn your character,
- Move away from the Position of 0,0,0,
- Change your rotation so it isn’t 0,0,0,
The error will occur then.
Workarounds
- Unknown.
Any recommendations to achieve this?
Script
This must go into an admin command, and you must be moved away from the original starting position of 0,0,0… else you will not recreate the error. This is triggered by an admin command, and is supposed to work no matter where the character looks, or is positioned in the world.
--[[This must go into an admin command, and you must be moved away from the original starting position of 0,0,0.. else you will not recreate the error. This is triggered by an admin command, and is supposed to work no matter where the character looks, or is positioned in the world.]]
task.wait(7)
local Workspace = game.Workspace;local PlayerName = "PUT_YOUR_PLAYERS_NAME_HERE"
if Workspace:FindFirstChild(PlayerName) and not Workspace:FindFirstChild(PlayerName.." Light") then
local ModelOfLight = Instance.new("Model");
ModelOfLight.Name = (PlayerName.." Light");
ModelOfLight.Parent = game.Workspace
local lightPart = Instance.new("Part");
lightPart.Parent = ModelOfLight;
ModelOfLight.PrimaryPart = ModelOfLight:FindFirstChild("Light");
local NewLight = Instance.new("SurfaceLight",lightPart);
local newWeld = Instance.new("Weld",lightPart)
newWeld.Part0 = lightPart;
newWeld.Part1 = Workspace[PlayerName].HumanoidRootPart;
lightPart.Massless = true
lightPart.Size = Vector3.new(0.7, 1.4, 2.2);
lightPart.Name = "Light";
lightPart.Anchored = false;
lightPart.CanCollide = false;
lightPart.Transparency = 0
ModelOfLight.PrimaryPart = ModelOfLight:WaitForChild("Light",30);
local PlayerPos = Workspace[PlayerName].PrimaryPart.Position
ModelOfLight.PrimaryPart.Position = Vector3.new(PlayerPos.X + 2,PlayerPos.Y + 3,PlayerPos.Z + 2)
--ModelOfLight.PrimaryPart.Orientation = Workspace[PlayerName].HumanoidRootPart.Orientation - Vector3.new(40,0,0)
NewLight.Range,NewLight.Brightness,NewLight.Face = 16,1,"Bottom"
end