Does anyone know how to make this script make it so the cube will spawn in front of you?
RemoteEvent Name: CUBE
Script in ServerScriptService:
local Event = game.ReplicatedStorage.CUBE
Event.OnServerEvent:Connect(function(Player)
local Part = Instance.new("Part")
Part.Size = Vector3.new(2, 2, 2)
Part.Parent = game.Workspace
Part.BrickColor = BrickColor.new("Ghost grey")
Part.Material = Enum.Material.SmoothPlastic
end)
LocalScript in StarterPlayerScripts:
local UIS = game:GetService("UserInputService")
local Event = game.ReplicatedStorage.CUBE
UIS.InputBegan:Connect(function(key,typing)
if typing then return end
if key.KeyCode == Enum.KeyCode.K then
Event:FireServer()
end
end)
I’m only looking to make it so it spawns in front of you
This would set its position to be where your Character is currently looking at, and you can set its 10 Number to how far you want it to spawn in front of you