What does ____.Value = new == mean?

I’m looking through the official Roblox Crossroads scripts and this is how reload works. A client calls a Module Script in Replicated Storage. Here is the Module Script used.

local HandleReload = {}

local TweenService = game:GetService("TweenService")
local Gui = script:WaitForChild("ReloadGui")

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

function HandleReload.new(Tool, ReloadTime)
	local Character = Player.Character
	local myScreenGui = Gui:Clone()
	local AncestryConnection = Tool.AncestryChanged:Connect(function(old, new)
		myScreenGui.Enabled = new == Character <---------- Right here!
	end)
	myScreenGui.Parent = PlayerGui
	local myTweenInfo = TweenInfo.new(ReloadTime, Enum.EasingStyle.Linear)
	local myTween = TweenService:Create(myScreenGui:FindFirstChild("ProgressFrame", true), myTweenInfo, {Size = UDim2.new(1, 0, 1, 0)})
	myTween:Play()
	myTween.Completed:connect(function()
		--could be flashier
		myScreenGui:Destroy()
		AncestryConnection:Disconnect()
	end)
end


return HandleReload

What does this mean, and is this script able to defend from hackers?

I don’t know what it means but I’m extremely sure it can’t defend from hackers. It might stop them a little bit, but exploiters are an unstoppable force that no code can prevent.

... = new == Character is basically like a short conditional that returns either true or false (don’t know the proper terminology) but the .AncestryChanged suggests that the tool instance gets its ancestry changed (its parent) and when the new ancestry is set, it checks if the parent is the players character in which case the tool is equipped, which then enabled a screengui.

local bool = 1 == 1 -- this should be true since 1 equals 1
1 Like

like @XxprofessgamerxX said, it is setting the Enabled property of the screen GUI to a conditional statement.
It’s easier to visualize it with some parenthesis:

myScreenGui.Enabled = (new == Character)

it is comparing “new” to “Character” to check if they are equal. Another way of writing this would be:

if new == Character then
   myScreenGui.Enabled = true
else 
   myScreenGui.Enabled = false
end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.