I msessed up the other post. But if you are new to this one then the problem is basiclly that I try to press R, it won’t work. But instead it focuses on every other key. I am trying to make a blocking input that activates when you press R. Here is the script:
--Blocking Script made by RinxfulROBLOX--
local ReplicatedStorage = game.ReplicatedStorage
local blockEvent = ReplicatedStorage.BlockEvent
local UserInputService = game:GetService("UserInputService")
local Blocking = Instance.new("BoolValue")--Setting BoolValue so when player presses F, blocking will be set to true
Blocking.Name = "Blocking"
Blocking.Value = false --Playing isn't blocking as of now
local player = game.Players.LocalPlayer
local character = script.Parent
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local meele = game.StarterPack.Meele
local equipped = false --Player won't be able to block if they don't have meele, or anytype of fighting style equipped
meele.Equipped:connect(function()
equipped = true
Blocking.Value = false
print(Blocking.Value)
end)
meele.Unequipped:connect(function()
equipped = false
Blocking.Value = false
print(Blocking.Value)
end)
Blocking.Parent = character --For me it makes it way eaiser to do this to communicate with the server
print(Blocking.Value)
local BlockingKeyCode = Enum.KeyCode.R
local BlockAnim = meele.BlockAnim
local function blockBegan(inputObject,gameProcessed)
--Checking if player pressed R, and meele is equipped, and they aren't blocking
if inputObject.KeyCode == BlockingKeyCode and equipped then
print("Blocking..")
Blocking.Value = true
print(Blocking.Value)
else
print("Not working")
end
end
local function blockEnded(inputObject,gameProcessed)
--Now that player is blocking and blocking is true, we gotta make it so that when they let go of R, blocking is set back to false
if inputObject.KeyCode == BlockingKeyCode and equipped and Blocking.Value == true then
print("Block ended")
Blocking.Value = false
print(Blocking.Value)
else
print("Not working")
end
end
UserInputService.InputBegan:connect(blockBegan)
UserInputService.InputEnded:connect(blockEnded)
I found a solutuin to the problem. BUT the problem is the meele. the “equipped” value I set isn’t working at all. And it seems like the meele:Equipped function doesn’t work. Here is the new script:
--Blocking Script made by RinxfulROBLOX--
local ReplicatedStorage = game.ReplicatedStorage
local blockEvent = ReplicatedStorage.BlockEvent
local UserInputService = game:GetService("UserInputService")
local Blocking = Instance.new("BoolValue")--Setting BoolValue so when player presses F, blocking will be set to true
Blocking.Name = "Blocking"
Blocking.Value = false --Playing isn't blocking as of now
local player = game.Players.LocalPlayer
local character = script.Parent
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local meele = game.StarterPack:WaitForChild("Meele")
local equipped = false --Player won't be able to block if they don't have meele, or anytype of fighting style equipped
meele.Equipped:connect(function()
equipped = true
print(equipped)
Blocking.Value = false
print(Blocking.Value)
if equipped then
print("Equipped")
end
end)
meele.Unequipped:connect(function()
equipped = false
print(equipped)
Blocking.Value = false
print(Blocking.Value)
if not equipped then
print("Not Equipped")
end
end)
Blocking.Parent = character --For me it makes it way eaiser to do this to communicate with the server
print(Blocking.Value)
local BlockingKeyCode = Enum.KeyCode.R
local BlockAnim = meele.BlockAnim
local function blockBegan(inputObject,gameProcessed)
--Checking if player pressed R, and meele is equipped, and they aren't blocking
if inputObject.KeyCode == BlockingKeyCode and equipped then
print("Blocking..")
Blocking.Value = true
print(Blocking.Value)
end
end
local function blockEnded(inputObject,gameProcessed)
--Now that player is blocking and blocking is true, we gotta make it so that when they let go of R, blocking is set back to false
if inputObject.KeyCode == BlockingKeyCode and equipped then
print("Block ended")
Blocking.Value = false
print(Blocking.Value)
end
end
UserInputService.InputBegan:connect(blockBegan)
UserInputService.InputEnded:connect(blockEnded)
I found a solution. Basiclly what the problem was that I didn’t set the script inside the meele. Looks like u can’t set a tool in another category but only inside the tool. I change the meele to meele = script.Parent. Script parent is the tool.