No matter what I do, read or anything, I can't understand what's going on. I can't really explain everything so, could anyone figure out what's wrong with this?
LocalScript:
local Tool = script.Parent;
local mouse = game.Players.LocalPlayer:GetMouse()
enabled = true
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local swapp = ReplicatedStorage:WaitForChild("CreatePartEvent")
function onEquipped()
Tool.Handle.BrickColor = BrickColor.Random()
end
Tool.Activated:connect(function()
local pos = mouse.Hit+Vector3.new(0,3,0)
pos = CFrame.new(pos.X,pos.Y,pos.Z)
if mouse.Target.Parent:FindFirstChild("Humanoid") ~= nil then
local player = game.Players.LocalPlayer.Name
local mousetargetto = mouse.Target.Parent.HumanoidRootPart
swapp:FireServer(player,mousetargetto)
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = pos
end
end)
script.Parent.Equipped:connect(onEquipped)
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage)
createPartEvent.Name = "CreatePartEvent"
local function onServerEvent(player,mousetargetto)
print(mousetargetto)
mousetargetto.Position = game.Workspace[player].HumanoidRootPart.Position
end
createPartEvent.OnServerEvent:Connect(onServerEvent)

2 comments
You have to explain what your script does.
It just teleports to another player with a humanoidrootpart. What I am trying to do is that the player will switch position with the other player. Kind of a body swap potion sort of thing.