I have been working for 3 days now on a tool script, its a sword script really.
I had everything working with FE turned off then I turned FE on and I have since then been working to re script everything so it works. I have all the damage working but its just not registering key presses.
There are 3 different scripts so be ready.
I have a local script, and two other normal scripts. The local script fires remote events that are supposed to fire on key presses. One of the normal scripts is the damage handler and the other is the main script.
This is the local script that fires the remote events on key presses
local UserInputService = game:GetService("UserInputService")
local KeyQPressedEvent = script.Parent:WaitForChild("KeyQPressed")
local KeyEPressedEvent = script.Parent:WaitForChild("KeyEPressed")
local KeyRPressedEvent = script.Parent:WaitForChild("KeyRPressed")
local function onKeyPressed(inputObject, gameProcessedEvent) -- Choke move
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.Q then
KeyQPressedEvent:FireServer()
end
elseif not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.E then -- Speed boost
end
elseif not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.R then -- Health boost
end
end
UserInputService.InputBegan:connect(onKeyPressed)
end
Heres the damage script
script.Parent.Blade.Touched:connect(function(hit)
if script.Parent.CanDamage.Value == true then
script.Parent.CanDamage.Value = false
local RandomDamage = math.random(1,3)
if RandomDamage == 1 then
hit.Parent.Humanoid:TakeDamage(75)
elseif RandomDamage == 2 then
hit.Parent.Humanoid:TakeDamage(80)
elseif RandomDamage == 3 then
hit.Parent.Humanoid:TakeDamage(85)
end
end
end)
And now heres the big boy. the main script, but mostly pay attention to the key input stuff because thats where I am having issues.
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local KeyQPressedEvent = script.Parent:WaitForChild("KeyQPressed")
local KeyEPressedEvent = script.Parent:WaitForChild("KeyEPressed")
local KeyRPressedEvent = script.Parent:WaitForChild("KeyRPressed")
local CanAttack = true
local SpecialActivated = false
script.Parent.Equipped:connect(function()
local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Equip)
local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local SwingAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SwingAttack)
local SideAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack)
local SideAttack2 = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack2)
local Choke = script.Parent.Parent.Humanoid:LoadAnimation(script.Choke)
local Trail = script.Parent.MainTrail.Trail
Trail.Attachment0 = Trail.Parent.Attachment
Trail.Attachment1 = Trail.Parent.Parent.Trail.Attachment
Equip:Play()
wait(1)
Idle:Play()
local function OnKeyQPressedFired(Player)
if SpecialActivated == false then
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
for _, TargetPlayer in pairs(game.Players:GetPlayers()) do
if TargetPlayer then
local TargetCharacter = TargetPlayer.Character
local Magnitude = (MainPlayer.Position - TargetCharacter:WaitForChild("HumanoidRootPart").Position).magnitude
if Magnitude < 25 and Magnitude > 0 then
SpecialActivated = true
Choke:Play()
MainPlayer.Parent.Humanoid.WalkSpeed = 0
MainPlayer.Parent.Humanoid.JumpPower = 0
for _, Parts in pairs(script.Parent:GetChildren()) do
if Parts and Parts:IsA("Part") or Parts:IsA("UnionOperation") or Parts:IsA("WedgePart") then
Parts.Transparency = 1
end
end
local Choking = TargetCharacter.Humanoid:LoadAnimation(script.Choking)
Choking:Play()
TargetCharacter.Humanoid.WalkSpeed = 0
TargetCharacter.Humanoid.JumpPower = 0
Choking.Stopped:connect(function()
TargetCharacter.Humanoid.WalkSpeed = 16
TargetCharacter.Humanoid.JumpPower = 50
TargetCharacter.Humanoid:TakeDamage(100)
end)
Choke.Stopped:connect(function()
SpecialActivated = false
for _, Parts in pairs(script.Parent:GetChildren()) do
if Parts and Parts:IsA("Part") or Parts:IsA("UnionOperation") or Parts:IsA("WedgePart") then
Parts.Transparency = 0
MainPlayer.Parent.Humanoid.WalkSpeed = 16
MainPlayer.Parent.Humanoid.JumpPower = 50
if Parts.Name == "Handle" then
Parts.Transparency = 1
end
end
end
end)
end
end
end
end
end
local function OnKeyEPressedFired(Player)
if SpecialActivated == false then
SpecialActivated = true
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local BlurEffect = Instance.new("BlurEffect")
MainPlayer.Parent:WaitForChild("Humanoid").WalkSpeed = 24
BlurEffect.Size = 5
BlurEffect.Enabled = true
BlurEffect.Parent = game.Workspace.CurrentCamera
wait(5)
MainPlayer.Parent:WaitForChild("Humanoid").WalkSpeed = 16
BlurEffect.Size = 0
BlurEffect.Enabled = false
SpecialActivated = false
end
end
local function OnKeyRPressedFired(Player)
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 600
MainPlayer.Parent:WaitForChild("Humanoid").Health = 600
wait(10)
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 450
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 450
end
KeyQPressedEvent.OnServerEvent:connect(OnKeyQPressedFired)
KeyEPressedEvent.OnServerEvent:connect(OnKeyEPressedFired)
KeyRPressedEvent.OnServerEvent:connect(OnKeyRPressedFired)
end)
script.Parent.Activated:connect(function()
local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Equip)
local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local SwingAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SwingAttack)
local SideAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack)
local SideAttack2 = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack2)
if CanAttack == true then
local RandomAttack = math.random(1,3)
if RandomAttack == 1 then
SwingAttack:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SwingAttack:Stop()
Idle:Play()
CanAttack = true
elseif RandomAttack == 2 then
SideAttack:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SideAttack:Stop()
Idle:Play()
CanAttack = true
elseif RandomAttack == 3 then
SideAttack2:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SideAttack2:Stop()
Idle:Play()
CanAttack = true
end
end
end)
There she is, I hope someone may be able to help. I know its a lot to take in at first but its actually quite simple. Thank you for your time :)
