Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script not Checking if BoolValue == true, Why?

So I have a a LocalScript that actives a RemoteFunctions. That RemoteFunction sets a BoolValue within the LocalPlayer to 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...

5 comments

0

I suppose your BoolValue is your variable Unlocked?

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

0

So i should make the local Unlocked = Unlock.Value inside the If statement

0

Thankyou So much, Ive been stuck on this for so long..

0

I mean your variable Unlocked is not needed. in your if statement, write if Unlock.Value then

2 answers

✓ Accepted answer

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.

1 comment

0

Im just messing around in Roblox Studio trying to get better, i dont expect the game to do well, Let along get visits

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

This discussion is preserved as it was. New answers, comments, and votes are closed.