-
What do you want to achieve?
For the Player to teleport correctly to the tool holder’s HumanoidRootPart and not away from it. -
What is the issue?
The Player being teleported is teleporting far from the tool holder’s HumanoidRootPart. It should be teleporting correctly because the HumanoidRootPart for the tool holder’s position is correct. -
What solutions have you tried so far?
I tried using Model:MoveTo() But that didn’t fix it at all.
--This code does the teleporting
player.Character.HumanoidRootPart.Position = Vector3.new(FlagValuesFolder.FlagObject.Value.Parent.HumanoidRootPart.Position)
Full Code
local FlagModule = {}
function FlagModule.FlagEquipped(uselesstable, flag)
local ReplicatedStorageService = game:GetService("ReplicatedStorage")
local FindFlagValueFolder = ReplicatedStorageService.FlagValues:FindFirstChild(tostring(flag))
local FindFlagEquippedValue
local FindFlagObjectValue
if FindFlagValueFolder then
FindFlagEquippedValue = FindFlagValueFolder:FindFirstChild("Equipped")
FindFlagObjectValue = FindFlagValueFolder:FindFirstChild("FlagObject")
if FindFlagEquippedValue then
FindFlagEquippedValue.Value = true
else
FindFlagEquippedValue = Instance.new("BoolValue", FindFlagValueFolder)
FindFlagEquippedValue.Name = "Equipped"
FindFlagEquippedValue.Value = true
end
if FindFlagObjectValue then
FindFlagEquippedValue.Value = flag
else
FindFlagEquippedValue = Instance.new("ObjectValue", FindFlagValueFolder)
FindFlagEquippedValue.Name = "FlagObject"
FindFlagEquippedValue.Value = flag
end
else
FindFlagValueFolder = Instance.new("Folder", ReplicatedStorageService.FlagValues)
FindFlagValueFolder.Name = tostring(flag)
if not FindFlagEquippedValue then
FindFlagEquippedValue = Instance.new("BoolValue", FindFlagValueFolder)
FindFlagEquippedValue.Name = "Equipped"
FindFlagEquippedValue.Value = true
end
if not FindFlagObjectValue then
FindFlagEquippedValue = Instance.new("ObjectValue", FindFlagValueFolder)
FindFlagEquippedValue.Name = "FlagObject"
FindFlagEquippedValue.Value = flag
end
end
end
function FlagModule.FlagUnequipped(uselesstable, flag)
local ReplicatedStorageService = game:GetService("ReplicatedStorage")
local FlagValuesFolder = ReplicatedStorageService:FindFirstChild(tostring(flag), true)
FlagValuesFolder.Equipped.Value = false
end
function FlagModule.TeleportToFlag(uselesstable, flagname, player)
local ReplicatedStorageService = game:GetService("ReplicatedStorage")
local FlagValuesFolder = ReplicatedStorageService:FindFirstChild(tostring(flagname), true)
if FlagValuesFolder then
if FlagValuesFolder.Equipped.Value == true then
player.Character.HumanoidRootPart.Position = Vector3.new(FlagValuesFolder.FlagObject.Value.Parent.HumanoidRootPart.Position)
end
end
end
return FlagModule
Also, I do not get any errors.
Here is a video of what happens:
robloxapp-20220405-0950398.wmv (1.7 MB)