So, I made an "attack" called force blast for my game, but instead of generating for 1 player, it generates for everyone. How do I fix it? Those are the scripts.
Also, if you can make it so it damages every player which touches it BUT the player which generated it, it would be great.
Video: https://streamable.com/hr84pm
Local Script.
local player = game.Players.LocalPlayer local character = script.Parent local remoteEvent = game.ReplicatedStorage:WaitForChild("forcebrr") local UserInputService = game:GetService("UserInputService") local requiredKey = Enum.KeyCode.R local rStorage = game.ReplicatedStorage local rep = game:GetService("ReplicatedStorage") UserInputService.InputBegan:Connect(function(key, gameProcessed) if key.KeyCode == requiredKey then remoteEvent:FireServer() end end)
Server Script.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("forcebrr") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) RemoteEvent.OnServerEvent:Connect(function(Player) --Part creation script is in the comments, it is right here but it is too long and will make the script harder to fix. end) end) end)
Part Creation Script:
local part = game.ServerStorage.ForceField:Clone() part.Parent = workspace part.Position = character.Torso.Position part.CanCollide = false part.Anchored = true part.Size = Vector3.new(5, 5, 5) part.Transparency = 0.05 wait(0.005) part.Size = Vector3.new(7.5, 7.5, 7.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(10, 10, 10) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(12.5, 12.5, 12.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(15, 15, 15) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(17, 17, 17) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(19, 19, 19) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(21, 21, 21) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(23, 23, 23) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(25, 25, 25) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(26.5, 26.5, 26.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(28, 28, 28) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(29.5, 29.5, 29.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(31, 31, 31) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(32.5, 32.5, 32.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(33.5, 33.5, 33.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(34.5, 34.5, 34.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(35.5, 35.5, 35.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(36, 36, 36) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(36.5, 36.5, 36.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part:Destroy()
Howdy! It looks to me that your problem is originating from the server script. I am new to scripting, so this may or may not work for you.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("forcebrr") local function forcebrrRemoteEvent(Player) local part = game.ServerStorage.ForceField:Clone() part.Parent = workspace part.Position = game.Players[Player.Name].Character.Torso.Position part.CanCollide = false part.Anchored = true part.Size = Vector3.new(5, 5, 5) part.Transparency = 0.05 wait(0.005) part.Size = Vector3.new(7.5, 7.5, 7.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(10, 10, 10) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(12.5, 12.5, 12.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(15, 15, 15) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(17, 17, 17) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(19, 19, 19) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(21, 21, 21) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(23, 23, 23) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(25, 25, 25) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(26.5, 26.5, 26.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(28, 28, 28) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(29.5, 29.5, 29.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(31, 31, 31) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(32.5, 32.5, 32.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(33.5, 33.5, 33.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(34.5, 34.5, 34.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(35.5, 35.5, 35.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(36, 36, 36) part.Transparency = part.Transparency + 0.05 wait(0.005) part.Size = Vector3.new(36.5, 36.5, 36.5) part.Transparency = part.Transparency + 0.05 wait(0.005) part:Destroy() end RemoteEvent.OnServerEvent:Connect(forcebrrRemoteEvent)
And for the local script
local player = game.Players.LocalPlayer local character = script.Parent local remoteEvent = game.ReplicatedStorage:WaitForChild("forcebrr") local UserInputService = game:GetService("UserInputService") local requiredKey = Enum.KeyCode.R local rStorage = game.ReplicatedStorage local rep = game:GetService("ReplicatedStorage") UserInputService.InputBegan:Connect(function(key, gameProcessed) if key.KeyCode == requiredKey then remoteEvent:FireServer(player) end end)
I apologize if this didn't work for you, as I didn't have any time to test it.