so im creating a game among us-like with 2 friends, we are doing good so far and we are trying to add kill script.
what im having problems with is not the kill itself, but the dead body. so for some reason the body appears in wrong place? im not getting any errors which is weird
i cannot see anything wrong here so any help would be appreciated heres the script
local Remote = game.ReplicatedStorage.Events.Kill
local RS = game.ReplicatedStorage
Remote.OnServerEvent:Connect(function(player,Pos,LV)
local Player1 = Region3.new(Vector3.new(1,1,1),Vector3.new(6,6,6))
local visualizePart = Instance.new("Part", game.Workspace)
visualizePart.Name = "HitboxTest"
visualizePart.Anchored = true
visualizePart.Size = Player1.Size
visualizePart.CFrame = Player1.CFrame
visualizePart.Color = Color3.new(255,0,0)
visualizePart.Transparency = 1
visualizePart.CanCollide = false
visualizePart.Position = Pos
local Region = Region3.new(visualizePart.Position-(visualizePart.Size/1.5),visualizePart.Position+(visualizePart.Size/1.5))
local Parts = workspace:FindPartsInRegion3(Region)
for i,v in pairs(Parts) do
print(v)
visualizePart:Destroy()
if v:IsA("Part") and v.Name == "HumanoidRootPart" then
local plr = v.Parent
print(plr.Name)
print(plr)
for i,v in pairs(game.ReplicatedStorage.CustomValues.SelectedPretenders:GetChildren()) do
if v.Value == player.Name then
local Check = game.ReplicatedStorage.CustomValues.SelectedPretenders:FindFirstChild(tostring(game.Players[plr.Name].UserId))
if not Check then
local Check2 = game.ReplicatedStorage.CustomValues.Ghosts:FindFirstChild(plr.Name)
if not Check2 then
if plr.Name ~= player.Name then
local PlayerF = Instance.new("Folder")
PlayerF.Parent = game.ReplicatedStorage.CustomValues.Ghosts
PlayerF.Name = plr.Name
local deadbodyclone = RS.DeadBody:Clone()
deadbodyclone.Parent = game.Workspace.DeadBodies
deadbodyclone:SetPrimaryPartCFrame(plr:FindFirstChild("Torso").CFrame)
local text = plr.Head:FindFirstChild("Nickname"):FindFirstChild("TextLabel")
text.TextColor3 = Color3.fromRGB(255, 255, 255)
break
end
end
end
end
end
end
end
end)
thanks!