So I have a tool that when you enable it and then click on a npc/enemy it should change both your root part cframes to a parts cframe i made in a model below the map. I can script the part that changes the cframes but I cant get the target part to work, heres what Ive done so far (the script isnt finished yet):
local Tool = script.Parent.Parent.Parent.Parent
Tool.OpenEvent.OnServerEvent:Connect(function(plr)
local rng = math.random(1,1)
print(rng)
if rng == 2 then
local Detect = Instance.new("Part",workspace)
Detect.Transparency = 1
Detect.Anchored = true
Detect.Size = Vector3.new(50,50,50)
Detect.CanCollide = false
Detect.CFrame = plr.Character.HumanoidRootPart.CFrame
Detect.Touched:Connect(function(hit)
if hit and hit.Parent == plr.Character then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local AttackPart = game.Workspace.AttackerPart
local EnemyPart = game.Workspace.EnemyTsukuPart
plr.Character:FindFirstChild("HumanoidRootPart").CFrame = AttackPart.CFrame
player.Character:FindFirstChild("HumanoidRootPart").CFrame = EnemyPart.CFrame
end
end
end
end)
(this goes in a server script)

3 comments
may i ask why this entire chunk of code is based upon a 1/1000 chance?
oh lol, typed that wrong
I fixed it, so what else in it wouldnt work