I'm trying to make a revolver that upon pressing 'e', a brick appears. I've been looking for a while, and I came across multiple people saying that in order to find the Torso of a character, it needs to be a local script. How can I make bricks spawn in front of the player without being client sided?
Basically, this is what I have so far. (The Local script.)
local tool = script.Parent local UserInputService = game:GetService("UserInputService") local connection local player = game.Players.LocalPlayer local function Connect() connection = UserInputService.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == Enum.KeyCode.E then script.RemoteEvent:FireServer() end end) end local function Disconnect() connection:Disconnect() end tool.Equipped:Connect(Connect) tool.Unequipped:Connect(Disconnect)
(The Regular script.)
local player = game.Players.LocalPlayer local wepen = script.Parent.Parent.Parent script.Parent.OnServerEvent:Connect(function(Player) local brick = Instance.new("Part",workspace) brick.Parent = workspace brick.CFrame = wepen.CFrame*CFrame.new(0,0,-5) wait(3) brick.Transparency = 0.1 wait(0.05) brick.Transparency = 0.2 wait(0.05) brick.Transparency = 0.3 wait(0.05) brick.Transparency = 0.4 wait(0.05) brick.Transparency = 0.5 wait(0.05) brick.Transparency = 0.6 wait(0.05) brick.Transparency = 0.7 wait(0.05) brick.Transparency = 0.8 wait(0.05) brick.Transparency = 0.9 wait(0.05) brick.Transparency = 1 wait(1) brick:Destroy() end)
Anytime I at least try to find the Torso, I always get an error.
The detection of pressing e:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "e" then print("Pressed e") end end)
The Plain old script:
local Players = game:GetService(“Players”) local wepen = script.Parent.Parent.Parent script.Parent.OnServerEvent:Connect(function(Player) local brick = Instance.new("Part",workspace) brick.Parent = workspace brick.CFrame = wepen.CFrame*CFrame.new(0,0,-5) wait(3) brick.Transparency = 0.1 wait(0.05) brick.Transparency = 0.2 wait(0.05) brick.Transparency = 0.3 wait(0.05) brick.Transparency = 0.4 wait(0.05) brick.Transparency = 0.5 wait(0.05) brick.Transparency = 0.6 wait(0.05) brick.Transparency = 0.7 wait(0.05) brick.Transparency = 0.8 wait(0.05) brick.Transparency = 0.9 wait(0.05) brick.Transparency = 1 wait(1) brick:Destroy() end)
script.Parent.OnServerEvent:Connect(function(Player) local brick = Instance.new("Part",workspace) brick.Parent = workspace brick.CFrame = Player.Character.Torso.CFrame*CFrame.new(0,0,-5) wait(3) brick.Transparency = 0.1 wait(0.05) brick.Transparency = 0.2 wait(0.05) brick.Transparency = 0.3 wait(0.05) brick.Transparency = 0.4 wait(0.05) brick.Transparency = 0.5 wait(0.05) brick.Transparency = 0.6 wait(0.05) brick.Transparency = 0.7 wait(0.05) brick.Transparency = 0.8 wait(0.05) brick.Transparency = 0.9 wait(0.05) brick.Transparency = 1 wait(4) brick:Destroy() end)