My script is supposed to spawn a brick in front of the player, I will use this as a hitbox for a “knockback” powerup.
The script is only working locally, the brick only spawns for the client and not other players. The location is as follows:
Here’s a example of what’s happening
https://gyazo.com/426f726f9226b48012c20a956b016d46
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
local RayOrigin = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local RayDestination = game.Players.LocalPlayer.Character.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector * 20
local RayDirection = RayDestination - RayOrigin
local ray = Ray.new(RayOrigin, RayDirection)
local part = Instance.new("Part")
local Distance = (RayOrigin - RayDestination).Magnitude
part.Size = Vector3.new(5,5,Distance)
part.Position = RayOrigin
part.CFrame = CFrame.lookAt(RayOrigin + RayDirection /2, RayOrigin + RayDirection)
part.Parent = workspace
part.BrickColor = BrickColor.Red()
part.Transparency = .5
part.Anchored = true
part.CanCollide = false
Instance.new("Part")
wait(5)
part:Destroy()
end
end)
Thanks in advance!