So, I wanna check when a player pressed a key to make a sort of "attack."
This is the current code which isn't working:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local UserInputService = game:GetService("UserInputService")
local key = Enum.KeyCode.R
local pressedkey = UserInputService:GetKeysPressed()
local function forceField()
for _, keypog in pairs(pressedkey) do
if (pressedkey.KeyCode == key) then
local part = Instance.new("Part",workspace)
part.Shape = Enum.PartType.Ball
part.Color3 = Color3.new(159, 243, 233)
part.Position = char.Torso.Position
part.CanCollide = true
part.Anchored = true
wait(1)
part.Size = Vector3.new(4.623, 4.623, 4.623)
part.Transperency = 0.1
wait(1)
part.Size = Vector3.new(5.305, 5.305, 5.305)
part.Transperency = 0.2
wait(1)
part.Size = Vector3.new(6.304, 6.304, 6.304)
part.Transperency = 0.3
wait(1)
part.Size = Vector3.new(7.569, 7.569, 7.569)
part.Transperency = 0.4
wait(1)
part.Size = Vector3.new(8.88, 8.88, 8.88)
part.Transperency = 0.5
wait(1)
part.Size = Vector3.new(10.247, 10.247, 10.247)
part.Transperency = 0.6
wait(1)
part.Size = Vector3.new(11.69, 11.69, 11.69)
part.Transperency = 0.7
wait(1)
part.Size = Vector3.new(13.387, 13.387, 13.387)
part.Transperency = 0.8
wait(1)
part.Size = Vector3.new(15.039, 15.039, 15.039)
part.Transperency = 0.9
wait(1)
part:Destroy()
end
end
end
end)
end)

1 comment
Also I just noticed your part creating and modification codes wouldn't work. Example: 'Color3' is not a property of part, it should be 'BrickColor3'