I have a tool, there’s a local script and server script. The problem is the server script so ingnore the local one if you like.
local script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Event = tool.RemoteEvent
local function onActivated()
local MouseHit = mouse.Hit.Position
Event:FireServer(mouse.Hit.Position)
end
local function onUnequipped()
--print("tool was unequipped")
end
local function onEquipped()
--print("tool was equipped")
end
tool.Activated:Connect(onActivated)
tool.Equipped:Connect(onEquipped)
tool.Unequipped:Connect(onUnequipped)
server script:
local Players = game:GetService("Players")
local Event = tool.RemoteEvent
local char = nil
local charOrientation = nil
Event.OnServerEvent:Connect(function(player, position)
--local ModelPart = game.ReplicatedStorage.Ground:Clone()
--ModelPart.Anchored = true
--ModelPart.CFrame = CFrame.new(position) * CFrame.new(0, 3.5, 0)
--ModelPart.Parent = game.Workspace
char = player.Character
--charOrientation = char:FindFirstChild("HumanoidRootPart").CFrame
--print(charOrientation)
char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position, position)
for i = 0, 5 do
if i == 0 then
local part = game.ReplicatedStorage.Ground:Clone()
part.Anchored = true
part.CFrame = CFrame.new(position) * CFrame.new(0, 3.5, 0)
part.Parent = game.Workspace
else
local part = game.ReplicatedStorage.Ground:Clone()
part.Anchored = true
part.CFrame = CFrame.new(position) * CFrame.new(0, 3.5, 0) * CFrame.new(i*4, 0, 0)
part.Parent = game.Workspace
end
end
end)
When i click, character faces the place i clicked and if i am in motion and click then i get teleported back a little. Is there a way to update the current position of player’s char?
I would appreciate any feedback!