What solutions have you tried so far?
Firstly im create Remote Event to set part position. Then i make script in ServerScriptService
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouse)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
part.CanCollide = true
part.Touched:Connect(function(hit)
if hit.Parent:FindfirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
After that I make tool with local script
And also script
local player = game.Players.LocalPlayer
local tool = script.Parent.Parent
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
local mouse = player:GetMouse()
if tool and Remote then
tool.Equipped:Connect(function(part)
part.Position = Vector3.new(mouse.Hit.Position.X,0.5, mouse.Hit.Position.Z)
Remote:FireServer(part)
end)
end
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouse)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
part.Position = Vector3.new(mouse.Hit.Position.X,0.5, mouse.Hit.Position.Z)
part.CanCollide = true
part.Touched:Connect(function(hit)
if hit.Parent:FindfirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
But there is new error
Hit is not a valid member of CFrame - Server
Stack Begin - Studio
Script âServerScriptService.PartPositionâ, Line 7 - Studio
Stack End - Studio
local player = game.Players.LocalPlayer
local tool = script.Parent.Parent
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
local mouse = player:GetMouse()
if tool and Remote then
tool.Equipped:Connect(function(part)
Remote:FireServer(mouse.Hit)
end)
end
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouseHit)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
part.Position = Vector3.new(mouseHit.Position.X,0.5, mouseHit.Position.Z)
part.CanCollide = true
part.Touched:Connect(function(hit)
if hit.Parent:FindfirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
Update server script with this. Should work this time.
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouseHit)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
part.Position = Vector3.new(mouseHit.Position.X,0.5, mouseHit.Position.Z)
part.CanCollide = true
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
local mouse = game.Players.LocalPlayer:GetMouse()
local part = workspace.Part
mouse.Move:Connect(function()
part.Position = Vector3.new(mouse.Hit.Position.X,0.5, mouse.Hit.Position.Z)
end)
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouseHit)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
mouseHit.Move:Connect(function()
part.Position = Vector3.new(mouseHit.Position.X,0.5, mouseHit.Position.Z)
end)
part.CanCollide = true
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
And i have problem
Move is not a valid member of CFrame
local Remote = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
if Remote then
Remote.OnServerEvent:Connect(function(player, mouseHit)
local part = Instance.new("Part",workspace)
part.BrickColor = BrickColor.new("Bright red")
part.CanCollide = true
part.Position = CFrame.new(mouseHit.Position.X,0.5, mouseHit.Position.Z)
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)
end
Unable to assign property Position. Vector3 expected, got CFrame - Server
Stack Begin - Studio
Script âServerScriptService.PartPositionâ, Line 8 - Studio
Stack End - Studio