Create a new RemoteEvent and name it “ActivePlayerRE” inside of ReplicatedStorage.
Create a LocalScript inside of the PlayButton.
Type in the following stuff.
local ActivePlayerRE = game.ReplicatedStorage:WaitForChild("ActivePlayerRE")
script.Parent.MouseButton1Click:Connect(function()
ActivePlayerRE:FireServer()
print("ActivePlayerRE has been fired!")
end)
Now create a new ServerScript inside of the ServerScriptService.
Type in the following stuff.
local ActivePlayerRE = game.ReplicatedStorage:WaitForChild("ActivePlayerRE")
local hitbox = gamr.ReplicatedStorage.Hitbox:Clone()
ActivePlayerRE.OnServerEvent:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
hitbox.Parent = char
hitbox.CFrame = char.Torso.CFrame
local motor = Instance.new("Motor6D", char.Torso)
motor.C0 = char.Torso.CFrame
motor.C1 = hitbox.CFrame
end)
And hopefully that helped. I’m not totally sure if it will work or not because I’m not in studio so. You can try and reply back if it worked or not! Glad to help.
EDIT: I might be wrong somewhere in the script. I’ll try to find it.
First off, you’re setting Box.Parent instead of the cloned HitBox.Parent. Secondly, you would need to set the Part0 of the motor to Torso and Part1 of the motor to the HitBox
local Box = Instance.new("Part")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local HitBox = Box:Clone()
HitBox.Parent = Character
HitBox.CFrame = Character.Torso.CFrame
local Motor = Instance.new("Motor6D",Character.Torso)
Motor.Part0 = Character.Torso
Motor.Part1 = HitBox
end)
end)