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

Having trouble getting RemoteEvents to check BoolValue?

Hello,

I have an FE-compatible gun script that works as is, thanks to the wonderful AlvinBloxx. But what I'd like for it to do is to change the amount of damage dealt, based on if certain BoolValues are set to true or not.

For example, what I'd love for it to be able to do is:

if player.Upgrades.HasRed.Value == true then
damage = 50
else if player.Upgrades.HasBlue.Value == true then
damage = 75
--etc.

The way the BoolValues are set is that neither can be true at once. But I realize I probably need to use a RemoteEvent for this, and I'm doing it wrong. :D I've read the Wiki, and hiimgoodpack's tutorial: https://forum.scriptinghelpers.org/topic/186/how-and-when-to-use-remoteevents-and-remotefunctions and these things are confusing.

I'm not getting any error outputs here, and the damage being dealt is not consistent.

Here's how my broken portion of the script is currently:

local serverStorage = game:GetService("ServerStorage")
local replicatedStorage = game:GetService("ReplicatedStorage").GunRemotes
local checkBoolValue = replicatedStorage:WaitForChild("CheckBoolValue")
local KOValue = "Kills"
local WOValue = "Wipeouts"



--Function to check BoolValues and establish Damage
checkBoolValue.OnServerEvent:Connect(function(player,value)
	local Item1 = player.Upgrades:FindFirstChild("HasRed")
	local Item2 = player.Upgrades:FindFirstChild("HasBlue"')
	if Item1.Value == true then
		damage = 50
	elseif Item2.Value == true then
		damage = 80
	elseif Item1.Value and Item2.Value == false then
		damage = 25
				
	end
end)

--Rest of Gun Script below

If there's a better way to do this, with or without using RemoteEvents, I'm all for it. Thank you. :)

6 comments

0

I don't think this is confusing.

0

hiimgoodpack - Since you wrote a tutorial on it, I'm reasonably confident you don't find remote events and remote functions confusing. However, I do. :D If you see any problems with how I have it laid out, I'd appreciate your input.

0

hiimgoodpack is rarely helpful anymore, and you shouldn't need a remote event to check a value. If you want to change the value just have it check in a local script and change it in a server script activated by a remote event.

0

What? I post about security issues that you can avoid with a simple step. If security is not important to you, then I don't know what is.

0

Viking359 - Thanks for the response. I don't want to change the value, I want the script to check to see if the Value is true, if true, then I want the damage dealt by the weapon to be changed. :) Thats what I'm a bit thrown off on. x.x

0

You should print debug it do figure out what line the script messes up on, and I'd use an if statement that checks the value in a local script then if it needs to change it fire a remote event that activates a server script which changes the damage value

1 answer

if Bool1.Value and Bool2.Value then -- check for both values as true.
	print("Both values true!")
elseif Bool1.Value then -- setting 1
	Damage = 80
elseif Bool2.Value then -- setting 2
	Damage = 50
else
	Damage = 25 -- no other possible combinations, neither are on.
end

EDIT: If your results are inconsistent, consider looking at the scripts that fire the remote events. No way to do it without remote events, unless you want hackers.

3 comments

0

Remember, remote event security that i showed in my tutorial.

0

H4X0MSYT - Thanks for the response, it doesn't seem to be working though. =/ I'm sure the problem is on my end.

0

It's just the code for checking... I'm sure anyone has the intelligence to understand remote events. Seriously, where do I ever see you answer? I only see you pointing out flaws in answers.

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