Ad
Log in to vote
0

Script not Checking if BoolValue == true, Why?

Asked by 10 days 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 363 — 10d
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 363 — 10d
0
So i should make the local Unlocked = Unlock.Value inside the If statement KoalaTech 6 — 10d
0
Thankyou So much, Ive been stuck on this for so long.. KoalaTech 6 — 10d
0
I mean your variable Unlocked is not needed. in your if statement, write if Unlock.Value then Spjureeedd 363 — 10d

2 answers

Log in to vote
0
Answered by 10 days 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 — 9d
Ad
Log in to vote
0
Answered by 10 days ago

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

Answer this question