I tried several ways to change the value but, it just won’t change, I’m not sure what I’m doing wrong.
ocal RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local CubeShiftEvent = RS:WaitForChild("CubeShiftEvent")
local RunSHift = RS:WaitForChild("BullRUN")
local model = game.ReplicatedStorage.StarterCharacter
local player = game.Players.LocalPlayer
local NVal = false
local otherSpirnt = game.StarterGui:WaitForChild("SprintScript")
local Humanoid = player.Character:WaitForChild("Humanoid")
----------------------------------
local VoidShift = RS:WaitForChild("Void")
local isRunning = false
local triggerKeyAttack = Enum.KeyCode.Z
UIS.InputBegan:Connect(function(input,gameProcessed)
local AbleRunning = false
local AbleStoped = false
local triggerKey = Enum.KeyCode.LeftShift
local REGULAR_SPEED = 16
local RUN_SPEED = 30
--------------------------------cooldowns
local SwordSwingCoolDown = 1
local CanAttack = true
-----------------
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
NVal = true
print("E is pressed Nval is set to",NVal)
--local newAv = model:Clone()
--newAv.Parent = game.StarterPlayer
AbleRunning = true
wait(.1)
CubeShiftEvent:FireServer(model)
--------------------------------------
end
end
end
---------------------------------------------------------Attacks
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Z and NVal then
print("z fired")
VoidShift:FireServer(CanAttack,SwordSwingCoolDown)
else
print("Value is flase")
end
end
Hi, could you please show us the output of the following script?
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local CubeShiftEvent = RS:WaitForChild("CubeShiftEvent")
local RunSHift = RS:WaitForChild("BullRUN")
local model = game.ReplicatedStorage.StarterCharacter
local player = game.Players.LocalPlayer
local NVal = false
local otherSpirnt = game.StarterGui:WaitForChild("SprintScript")
local Humanoid = player.Character:WaitForChild("Humanoid")
----------------------------------
local VoidShift = RS:WaitForChild("Void")
local isRunning = false
local triggerKeyAttack = Enum.KeyCode.Z
UIS.InputBegan:Connect(function(input,gameProcessed)
print("Starting our connection with NVAL having the value of ", tostring(NVal))
local AbleRunning = false
local AbleStoped = false
local triggerKey = Enum.KeyCode.LeftShift
local REGULAR_SPEED = 16
local RUN_SPEED = 30
-- Cooldowns --
local SwordSwingCoolDown = 1
local CanAttack = true
-- --
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
print("Continuing our connection with NVAL having the value of ", tostring(NVal))
NVal = true
print("E is pressed Nval is set to",NVal)
--local newAv = model:Clone()
--newAv.Parent = game.StarterPlayer
AbleRunning = true
task.wait(.1)
print("Ending our connection with NVAL having the value of ", tostring(NVal))
CubeShiftEvent:FireServer(model)
end
end
end
-- Attacks --
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Z and NVal then
print("z fired")
VoidShift:FireServer(CanAttack,SwordSwingCoolDown)
else
print("Value is flase")
end
end
end)
I just pasted your script into my studio and it prints e correctly but z wrong. Here’s why
You put both the e and z functions in the same connection of InputBegan
Put the z function in another connection like this
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local CubeShiftEvent = RS:WaitForChild("CubeShiftEvent")
local RunSHift = RS:WaitForChild("BullRUN")
local model = game.ReplicatedStorage.StarterCharacter
local player = game.Players.LocalPlayer
local NVal = false
local otherSpirnt = game.StarterGui:WaitForChild("SprintScript")
local Humanoid = player.Character:WaitForChild("Humanoid")
----------------------------------
local VoidShift = RS:WaitForChild("Void")
local isRunning = false
local triggerKeyAttack = Enum.KeyCode.Z
UIS.InputBegan:Connect(function(input,gameProcessed)
print("Starting our connection with NVAL having the value of ", tostring(NVal))
local AbleRunning = false
local AbleStoped = false
local triggerKey = Enum.KeyCode.LeftShift
local REGULAR_SPEED = 16
local RUN_SPEED = 30
-- Cooldowns --
local SwordSwingCoolDown = 1
local CanAttack = true
-- --
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
print("Continuing our connection with NVAL having the value of ", tostring(NVal))
NVal = true
print("E is pressed Nval is set to",NVal)
--local newAv = model:Clone()
--newAv.Parent = game.StarterPlayer
AbleRunning = true
task.wait(.1)
print("Ending our connection with NVAL having the value of ", tostring(NVal))
CubeShiftEvent:FireServer(model)
end
end
end
-- Attacks --
end)
UIS.InputBegan:Connect(function(input,gameproccessevent)
if not gameproccessevent then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Z and NVal then
print('z')
VoidShift:FireServer(model)
else
print('nval is fasle')
end
end
end
end)