Returning true / false

ok hi guys i need some help with returning true or false

so heres my local script

local
script.Parent.Parent.Back.upgrade.MouseButton1Click:Connect(function()
	if obj.Parent.upgradeable.Value == true then
		local payed = game.ReplicatedStorage.signals.remotes.events.upgrade:FireServer(obj)
		watching = false

		if payed == true then
			
              -- do stuff			

		else
			script.Parent.Parent.Back.upgrade.Text = "Failed to Upgrade"
		end
	else
		script.Parent.Parent.Back.upgrade.Text = "You can't upgrade this."
	end
end)

i always get the ‘failed to upgrade’ instead of do stuff (removed code bc yeah)
this is the server script that handles the upgrade event

server
-- services
local rs = game:GetService('ReplicatedStorage')

-- code
rs.signals.remotes.events.upgrade.OnServerEvent:Connect(function(plr,obj)
	if obj.Parent:FindFirstChild('hitbox') then
		local hitbox = obj.Parent:FindFirstChild('hitbox')
		if hitbox.Parent.upgradeable.Value == true then
              -- some more hidden code

				print('upgraded')
				return true
			else
				return false
			end
		else
			return false
		end
	else
		return false
	end
end)

in the server script, it still prints (‘upgraded’) and the hidden code runs

thanks if u can help

Use a RemoteFunction instead of a RemoteEvent if you want a return to be given

2 Likes