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

Having trouble getting RemoteEvents to check BoolValue?

Asked by 6 years ago
Edited 6 years ago

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. :)

0
I don't think this is confusing. hiimgoodpack 2009 — 6y
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. Never2Humble 90 — 6y
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. Viking359 161 — 6y
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. hiimgoodpack 2009 — 6y
View all comments (2 more)
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 Never2Humble 90 — 6y
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 Viking359 161 — 6y

1 answer

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago
Edited 6 years ago
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.

0
Remember, remote event security that i showed in my tutorial. hiimgoodpack 2009 — 6y
0
H4X0MSYT - Thanks for the response, it doesn't seem to be working though. =/ I'm sure the problem is on my end. Never2Humble 90 — 6y
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. H4X0MSYT 536 — 6y
Ad

Answer this question