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

Script not Checking if BoolValue == true, Why?

Asked by 3 years ago

So I have a a LocalScriptthat actives a RemoteFunctions. That RemoteFunctionsets a BoolValuewithin the LocalPlayerto true, on the Server and Client.

These scripts are working perfectly fine ^

I have another script where if you click F on your keyboard it will check if

if debounce == false and BoolValue == true then

But even if that BoolValue== true then script thinks its false and it says "You need to Unlock the move"

local Player = game:GetService("Players").LocalPlayer

local UIS = game:GetService("UserInputService")
local Sounds = game:GetService("ServerScriptService")
local Unlock = Player.Unlocks:WaitForChild("Magic: Raitoningu")
local Unlocked = Unlock.Value

local debounce = false
local cooldown = 8

local rp = game:GetService("ReplicatedStorage")
local RE = rp["Magic: Raitoningu"]

function cameraShake()
    local Character = Player.Character

    local length = 10
    for i = 1, length do
        Character.Humanoid.CameraOffset = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1))
        wait()
    end
    Character.Humanoid.CameraOffset = Vector3.new(0,0,0)
end
wait(1)
UIS.InputBegan:Connect(function(input,isTyping)
    if isTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.F then
        if Unlocked == false then
            print("You need to Unlock the move")
        end
        if debounce == true then
            print("Youre on Cooldown")
        end

        if debounce == false and Unlocked == true then
            debounce = true
            RE:FireServer()


            spawn(function()
                wait(.75)
                cameraShake()
            end)
        end
    end
end)


RE.OnClientEvent:Connect(function()
    wait(cooldown)
    debounce = false
    print("Magic: Raitoningu Ready")
end)

Sorry if this post sucks, I havent posted in a while...

0
I suppose your BoolValue is your variable Unlocked? Spjureeedd 385 — 3y
0
This problem is actually rather simple. Your variable Unlocked saves the Value at that time, when the script creates the variable, if Unlock.Value changes after that, the value of the variable will still be the same Spjureeedd 385 — 3y
0
So i should make the local Unlocked = Unlock.Value inside the If statement KoalaTech 6 — 3y
0
Thankyou So much, Ive been stuck on this for so long.. KoalaTech 6 — 3y
0
I mean your variable Unlocked is not needed. in your if statement, write if Unlock.Value then Spjureeedd 385 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

It would be easier to just fire the event and check if it's unlocked in the server script. This would prevent exploiters from spamming as well.

0
Im just messing around in Roblox Studio trying to get better, i dont expect the game to do well, Let along get visits KoalaTech 6 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

All I had to do was put the Variable inside the if statement

Answer this question