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