Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The script works perfectly in studio but in game it doesn't work when input has ended, help?

Asked by
Jirozu 71
6 years ago

The script works perfectly in studio but in game it doesn't work when input has ended.

--//LOCAL SCRIPT:

--{(Local Script "Blocking"}}--
--{Input Started
UserInputService.InputBegan:connect(function(input, gameProcessed)
    if input.KeyCode ~= Enum.KeyCode.E then return end;
    if gameProcessed then
    else
        if CombatEnabled or EvadingEnabled == true then return end;
        if BlockingEnabled == false then
            BlockingEnabled = true
            BlockingValue.Value = true
            print("Blocking")
            --{RemoteEvent
            ReplicatedStorage.RemoteEvents.CombatEvents.BlockEvent:FireServer()
        end
    end
end)
--{Input Ended
UserInputService.InputEnded:connect(function(input, gameProcessed)
    if input.KeyCode ~= Enum.KeyCode.E then return end;
    if gameProcessed then
    else
        if BlockingEnabled == true then
            BlockingEnabled = false
            BlockingValue.Value = false
            print("Done blocking")
        end
    end
end)

--//SCRIPT:

--{{Script "Blocking}}--
--{While blocking value is true
ReplicatedStorage.RemoteEvents.CombatEvents.BlockEvent.OnServerEvent:connect(function(Player)
    --{Preset Animations
    local Animation = Player.Character.Humanoid:LoadAnimation(ReplicatedStorage.Animations.Combat.Block)
    local current = Animation
    --{Call Value
    local isBlocking = Player.Character.HumanoidRootPart.IsBlocking
    --{MAIN}--
    isBlocking.Value = true
    BlockingValue.Value = true
    Player.Character.Humanoid.WalkSpeed = Player.Character.Humanoid.WalkSpeed - 8
    while BlockingValue.Value == true and wait() do
        --{Animation
        current:Play()
        print(BlockingValue.Value)
        if BlockingValue.Value == false then
            Player.Character.Humanoid.WalkSpeed = Player.Character.Humanoid.WalkSpeed+8
            current:Stop()
        break end
    end
end)

Can I get some help?

0
You didn't define "ReplicatedStorage".. does "Done Blocking" never print? Goulstem 8144 — 6y
0
@Goulstem I defined ReplicatedStorage just now, and "Done Blocking" does not print while in game. Jirozu 71 — 6y

Answer this question